#define Pull_down_button_pin 2 #define Red_led_pin 3 #define Pull_up_button_pin 21 #define Blue_led_pin 20 int Pull_down_buttonState = 0; // variable for reading the pushbutton status int Pull_up_buttonState = 0; // variable for reading the pushbutton status void setup() { // initialize digital pins for LEDS as an output and buttons as INPUTS pinMode(Red_led_pin, OUTPUT); pinMode(Pull_down_button_pin, INPUT); pinMode(Blue_led_pin, OUTPUT); pinMode(Pull_up_button_pin, INPUT); } // the setup function runs once when you press reset or power the board void loop() { Pull_down_buttonState = digitalRead(Pull_down_button_pin); Pull_up_buttonState = digitalRead(Pull_up_button_pin); // check if the pushbutton is pressed. If it is, the buttonState is HIGH: if (Pull_down_buttonState == HIGH) { // turn LED on: digitalWrite(Red_led_pin, HIGH); } else { // turn LED off: digitalWrite(Red_led_pin, LOW); } if (Pull_up_buttonState == LOW) { // turn LED on: digitalWrite(Blue_led_pin, HIGH); } else { // turn LED off: digitalWrite(Blue_led_pin, LOW); } }