/*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); // defining rx (receiver) and tx(transmitter) for serial communication // constants won't change. They're used here to set pin numbers: const int buttonPin = 3; // defining the number of the pushbutton pin const int LED = 7; // defining the number of the LED pin // variables will change: int buttonState = 0; // variable for reading the pushbutton status void setup() { pinMode(LED, OUTPUT); // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT_PULLUP); // initialize input by activating the internal resistor on ATtiny44 serial.begin(9600); // begin serial communication at 9600 bits per second } void loop() { // the loop function runs over and over again forever buttonState = digitalRead(buttonPin); // read the state of the pushbutton value: if (buttonState == LOW) { // check if the pushbutton is pressed, turn LED on: serial.write('2'); // to print the specific alphabet on serial monitor when button pressed 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 { // turn LED off: digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW } }