No Serial Output/Input on Pins 6 & 7

Using a simple Pot reading and trying to send out the Serial pin (Pin 6). I have tried Serial1 and different ways of trying this. The information can be seen in the Serial Monitor in the Arduino IDE, I just can’t get it to send out or receive on the UART pins.

const int potPin = A0;
const int pinStateIn = 9;   //pinstate 9 on XB and IN 9 on Metro
const int pinStateLed = 8;  // out to LED pinstate switch indicator
//Variables:
//Value from pot
int potVal = 0;
int potValPrev = 0;

void setup() {
  //Start the serial communication.Baud rate must be the same as is on xBee module
  //Serial.begin(38400);
  Serial1.begin(38400);
  while (!Serial1){};
  pinMode(pinStateIn, INPUT);
  pinMode(pinStateLed, OUTPUT);
}
void loop() {
  
  int pinState = digitalRead(pinStateIn);
  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (pinState == HIGH) {
    // turn LED on:
    digitalWrite(pinStateLed, HIGH);
  } else {
    // turn LED off:
    digitalWrite(pinStateLed, LOW);
  }


  //Read the analog value from pot and store it to "value" variable
  potVal = analogRead(potPin);
  //Map the analog value to pwm value
  potVal = map (potVal, 2, 1023, 0, 255);

  if (abs(potVal - potValPrev) > 2)     //(abs(currValue - prevValue) > 5)

    if (potVal != potValPrev) {
      //while (Serial.available());
      //Serial.print('<');
      Serial1.print('<');
      //Serial.print(potVal);
      Serial1.print(potVal);
      //Serial.print('>');
      Serial1.println('>');
      potValPrev = potVal;
      Serial1.flush();
      delay (5); 
    }
}```

Is it even possible to transmit serial information out of this on the pin labeled TX???

Which XIAO are you using?

Thank you, Citric, for asking. It’s a SAMD21. I finally figured out how to properly monitor the serial information. The unit seems to be working fine as long as I don’t interfere too much. :crazy_face:

1 Like