/* created 2005 by DojoDave modified 30 Aug 2011 by Tom Igoe This example code is in the public domain. http://www.arduino.cc/en/Tutorial/Button */ const int pinBoton = 8; // the number of the pushbutton pin const int pinLed = 3; // the number of the LED pin int estadoBoton = 1; // variable for reading the pushbutton status void setup() { // initialize the LED pin as an output: pinMode(pinLed, OUTPUT); // initialize the pushbutton pin as an input_pullup: pinMode(pinBoton, INPUT_PULLUP); } void loop() { // https://www.arduino.cc/en/Reference/DigitalRead // read the state of the pushbutton value: estadoBoton = digitalRead(pinBoton); // check if the pushbutton is pressed. if it is, the buttonState is ON: if (estadoBoton == LOW) { // https://www.arduino.cc/en/Reference/DigitalWrite // turn LED oN: digitalWrite(pinLed, HIGH); delay(3000); } else { // turn LED oFF: digitalWrite(pinLed, LOW); delay(3000); } }