#define LED 4
#define PUSH_BUTTON 14
void setup() {
Serial.begin(115200);
pinMode(LED, OUTPUT);
pinMode(PUSH_BUTTON, INPUT_PULLDOWN);
}
/*
here we used a PULL_DOWN resistor which in case the button is not
pressed the read is 0 so the LED will be turned off and if the button
is pressed the read is 1 so the LED will be turned on
*/
void loop() {
int push_button_read = digitalRead(PUSH_BUTTON);
if(push_button_read == 1){
digitalWrite(LED, HIGH);
Serial.print("Button is pressed, push button read: ");
Serial.println(push_button_read);
}
else{
digitalWrite(LED, LOW);
Serial.print("Button is not pressed, push button read: ");
Serial.println(push_button_read);
}
delay(1000);
}