Controllo led via Seriale

credo di aver trovato un problema con la scheda, infatti non funziona neanche con del codice che ho trovato su internet:

#define LEDPIN 13

int state = LOW;
char incomingByte = 0;

void setup() {
  Serial.begin(9600);
  pinMode(LEDPIN, OUTPUT);
}

void loop() {
  
  // send data only when you receive data:
  if (Serial.available() > 0) {
     // we receive a char representing an integer. let's converto to int
    int incomingState = (Serial.read() == '1');
    
    // say what you got:
    Serial.print("I received: ");
    Serial.println(incomingState, DEC);
    
    if(incomingState != state) {
      state = incomingState;
      digitalWrite(LEDPIN, state); // turns the LED on or off
      Serial.print("Setting LED as: ");
      Serial.println(state);
    }
    else {
      Serial.print("Doing nothing. LED already: ");
      Serial.println(state);
    }
  }
}

praticamente se io immetto 1 ottengo:

I received: 1
Setting LED as: 1
e subito dopo
I received: 0
Setting LED as: 0

come se dopo il char 1 venisse inviato un char 0 mentre in teoria doveva esserci solo il primo, adesso provo con un'altra scheda XD