#define LED 2
#define BUTTON 4
int buttonState = 0;
void setup() {
pinMode(LED, OUTPUT);
pinMode(BUTTON, INPUT);
}
void loop() {
buttonState = digitalRead(BUTTON);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(LED, HIGH);
} else {
// turn LED off:
digitalWrite(LED, LOW);
}
}