/* * The code is for turning the LED ON when THe button pressed and blinking when its not. * This code originally made by Eidha Alrashdi for fablab 2018 * 17/3/2018 */ const int buttonPin = 3;// The button is connect in pin 3 which is PA3 const int ledPin = 7;// The button is connect in pin 7 which is PA7 void setup()// here we define { pinMode(3, INPUT);// Here I idintfy that button is input. pinMode(7, OUTPUT);// Here I idintfy that LED is output. } void loop()// here the code will be repeated { buttonState = digitalRead(3); if (buttonState == LOW) // If the button is pressed LED will turned ON. { digitalWrite(7, HIGH);// high means 1 or ON } else// if it is not pressed the LED will flash { //Flash: digitalWrite(7, HIGH); delay(100); // digitalWrite(7, LOW); delay(100); digitalWrite(7, HIGH); delay(100); digitalWrite(7, LOW); delay(100); } }