const int ledPin = 15; // GPIO pin for LED
const int buttonPin = 14; // GPIO pin for Push Button
void setup() {
Serial.begin(115200); // Initialize serial communication
pinMode(ledPin, OUTPUT); // Set the LED pin as output
pinMode(buttonPin, INPUT_PULLUP); // Set the button pin as input with internal pull-up
}
void loop() {
int buttonState = digitalRead(buttonPin); // Read the state of the push button
if (buttonState == HIGH) { // Button is pressed
digitalWrite(ledPin, HIGH); // LED stays ON
} else { // Button is NOT pressed
digitalWrite(ledPin, LOW); // LED stays OFF
delay(500); // Wait for half a second
digitalWrite(ledPin, HIGH); // Turn the LED ON
delay(500); // Wait for another half second
}
}