int LED = 7; // my LED is pin 7 int BUTTON = 3; // my button is pin 3 int BUTTON_value = 0; //variable to read the button pin void setup() { pinMode (LED, OUTPUT); // my LED is an output pinMode (BUTTON, INPUT_PULLUP); // my button is an input (pullup) } void loop() { BUTTON_value = digitalRead(BUTTON); // read the value of the button if (BUTTON_value == HIGH) { //when the button is not pressed digitalWrite(LED, LOW);//the LED is off } else { digitalWrite(LED, HIGH);//the LED is on } }