#include SoftwareSerial mySerial(7, 8); // RX, TX int node_id = 2; // node id int ledPin = 9; // LED pin number int ledGND = 10; // For OutputDevice only, LED cathode is connected to D10 int incoming = 0; // for incoming serial data void setup() { mySerial.begin(9600); mySerial.setTimeout(10); // Set Timout for separated numbers pinMode(ledPin, OUTPUT); pinMode(ledGND, OUTPUT); digitalWrite(ledGND, LOW); } void loop() { // check if data is available if (mySerial.available() > 0) { // read the incoming data incoming = mySerial.parseInt(); // say what you got for debugging // mySerial.print("I received: "); // mySerial.println(incoming); } // check if incoming data is for me // if so and data ends with '1' turn LED ON, when data ends with '0' turn LED OFF if (incoming == node_id * 10 + 1) { // turn LED on: digitalWrite(ledPin, HIGH); } else if (incoming == node_id * 10){ // turn LED off: digitalWrite(ledPin, LOW); } }