J'essaye d'allumer une LED quand un certain message arrive sur le port série mais rien ne fonctionne! s'il vous plaît aidez-moi !!arduino serial AIDEZ-MOI
int awsState = "AWS:0"; // for incoming serial data
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop() {
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
awsState = Serial.read();
// say what you got:
Serial.print(incomingByte);
Serial.println("Good");
if (awsState == "AWS:1"){
digitalWrite(13, HIGH);
}
else if (awsState == "AWS:0"){
digitalWrite(13, LOW);
}
}
}
Où est défini 'incomingByte'? Regardez ["Arduino - SoftwareSerial: read"] (https://www.arduino.cc/en/Reference/SoftwareSerialRead) ... Cette fonction renvoie seulement un caractère à la fois, pas le message complet. –
Veuillez toujours faire un ** Outils> Format automatique ** sur votre code avant de le poster. – per1234