// defining the pushbutton's pin
const int pushButton = 5;
// defining the LED's pin
const int led = 12;
void setup() {
Serial.begin(115200);
// Setting the pushbutton's pin as INPUT_PULLUP to enable internal pull-up resistor
pinMode(pushButton, INPUT_PULLUP);
// Setting the LED pin as an output
pinMode(led, OUTPUT);
}
void loop() {
int buttonState = digitalRead(pushButton);
if (buttonState == HIGH) {
digitalWrite(led, HIGH);
Serial.println("LED ON");
} else {
digitalWrite(led, LOW);
Serial.println("LED OFF");
}
delay(1000);
}