/* * When the it recive 1 from the master it will turn OFF the LED if it recive 0 it will turn ON. * Made by Eidha alrashdi * fabacadmy2018 *20/6/2018 * * */ #include// add serial library int rxPin = 0;// the receiver will be in pin 0 int txPin = 1;// the sender will be in pin 1 char val = '1';// defining that val is equal to 1 SoftwareSerial myserial(rxPin, txPin);// defin the serial and indecate the ports. void setup() { myserial.begin(9600); pinMode(5, OUTPUT);// pin 5 is the LED } void loop() { char chr = myserial.read();// chr will equal whatever the serial read if (chr == val) {// here I'm saying if the serial read a valuy equal to what val is turn LED off and send that it receive. digitalWrite(5, LOW);// turning the LED off myserial.write("attiny_recive");// slave 1 confirming reciving from master. delay(1000);// I made it 1 second to see the process. } else { digitalWrite(5, HIGH);// if it didnt receive 1 so it will turn ON LED } }