/* * Group Sofware Serial Node LED code * This code reads incomming data and sends it back over the Software serial line (if needed). * Next it turns the internal LED on when the received data is its ID. * It turns the LED off when the received data is 0. * This code is based on the work of Cody Bradly at http://www.ernstc.dk/arduino/tinycom.html * and on the SoftwareSerialExample Tom Igoe * * Date 2019-04-25 * Author Joey van der Bie * */ #include const int RX = 0; const int TX = 1; const int NODEID = 2; SoftwareSerial mySerial(RX, TX); int received = 0; const int LED_PIN = 7; void setup() { pinMode(RX, INPUT); pinMode(TX, OUTPUT); mySerial.begin(9600); // declare the LED pin as an OUTPUT: pinMode(LED_PIN, OUTPUT); } void loop() { if ( mySerial.available() ) { received = mySerial.parseInt(); mySerial.println(received); if(received == NODEID){ //turn LED on digitalWrite(LED_PIN, HIGH); } if(received == 0){ // turn LED off digitalWrite(LED_PIN, LOW); } } // delay(10); }