/*code sourced from Eidha Al Rashdi, fellow student at Fab Lab UAE. http://fab.academany.org/2018/labs/fablabuae/students/eidha-alrashdi/week14.html ----------------- Modified by Darshan Shah, during Fab Academy 2018.*/ #include // include software serial library SoftwareSerial serial(0,1); // definig rx (receiver) and tx(transmitter) for serial communication // constants won't change. int LED = 7; // defining led pin as an integer char turnON = '2'; // defining character transmitted from sender to turn on the led void setup() { // the setup function runs once I press reset or power the board pinMode(LED, OUTPUT); // initialize digital pin LED as an output. serial.begin(9600); // begin serial communication at 9600 bits per second } void loop() { // the loop function runs over and over again forever if (serial.available()>0){ // receive data when transmitted char state = serial.read(); // to read the character state in serial monitor serial.print("hh"); // to print the specific alphabet on serial monitor when button pressed if ( state == turnON) // if state reads the data that has transmitted then, { digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level) delay(2000); // delay for 2000 milliseconds (2 seconds) digitalWrite(LED, LOW); // turn the LED off delay(400); // delay for 400 milliseconds (0.4 seconds) // repeat the loop function digitalWrite(LED, HIGH); delay(400); digitalWrite(LED, LOW); delay(400); digitalWrite(LED, HIGH); delay(400); digitalWrite(LED, LOW); delay(400); digitalWrite(LED, HIGH); delay(400); digitalWrite(LED, LOW); delay(400); } else { digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW } } }