#define BUTTON_PIN 2 /* Push button connected to pin 2 */
#define LED_PIN 13 /* LED connected to pin 13 */
void setup() {
pinMode(BUTTON_PIN, INPUT_PULLUP); /* Set button as input with pull-up */
pinMode(LED_PIN, OUTPUT); /* Set LED as output */
}
void loop() {
if (digitalRead(BUTTON_PIN) == LOW) { /* If button is pressed */
digitalWrite(LED_PIN, HIGH); /* Turn LED ON */
} else {
digitalWrite(LED_PIN, LOW); /* Turn LED OFF */
}
}