#define BUTTON_PIN 27 // GPIO connected to the pushbutton
#define LED_PIN 4 // GPIO connected to the red LED
void setup() {
pinMode(BUTTON_PIN, INPUT_PULLUP); // Set pushbutton pin as input with pull-up resistor
pinMode(LED_PIN, OUTPUT); // Set LED pin as output
}
void loop() {
// Read the pushbutton state
int buttonState = digitalRead(BUTTON_PIN);
if (buttonState == LOW) { // Button pressed (active low)
digitalWrite(LED_PIN, HIGH); // Turn on the LED
Serial.println("its on");
} else {
digitalWrite(LED_PIN, LOW); // Turn off the LED
Serial.println("its off");
}
}