// read date from the serial and turn ON or OFF a light depending on the value char val; //Data received from the serial port int ledPin = D8; //Set the pin to digital I/O D8 void setup() { pinMode (ledPin, OUTPUT); //set pin as OUTPUT //Serial.swap(1); //Use alternate pins for tx-rx Serial.begin(9600); //Start serial communication at 9600 bps } void loop() { if (Serial.available()) { //if data is available to read, val = Serial.read(); //read it and store it in val } if (val == 'H') { //if H was received digitalWrite(ledPin, HIGH); //turn the LED on } else { digitalWrite(ledPin, LOW); //Otherwise turn it OFF } delay(100); //wait 100 milliseconds for next reading }