const int buttonPin = 0; // the number of the pushbutton pin const int ledPin = 1; // the number of the LED pin // variables will change int ledState = 0; // variable for ON/OFF led void setup() { pinMode(ledPin, OUTPUT); // initialize the LED pin as an output pinMode(buttonPin, INPUT); // initialize the pushbutton pin as an input digitalWrite(ledPin, LOW); // setting up led OFF for beginning } void loop() { if (digitalRead(buttonPin) == LOW){ // checking if button is pressed if (ledState == 0){ //if led is OFF ledState = 1; digitalWrite(ledPin, HIGH); // setting led ON } else { // if led is ON ledState = 0; digitalWrite(ledPin, LOW); // setting led OFF } delay(500); } }