#define BUTTON_PIN 2
#define DOWN LOW
#define UP HIGH
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(BUTTON_PIN, INPUT_PULLUP);
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
if (digitalRead(BUTTON_PIN) == DOWN) {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
} else {
digitalWrite(LED_BUILTIN, LOW); // turn the LED on (HIGH is the voltage level)
}
}
// some people build their if statements like this
// void loop() {
// if (digitalRead(BUTTON_PIN) == DOWN)
// {
// digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
// }
// else
// {
// digitalWrite(LED_BUILTIN, LOW); // turn the LED on (HIGH is the voltage level)
// }
// }