const int ledPin = 15; // LED + resistor to GPIO 15
const int buttonPin = 14; // button to GPIO 14
void setup() {
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
// INPUT_PULLUP means button unpressed → HIGH; pressed → LOW
pinMode(buttonPin, INPUT_PULLUP);
}
void loop() {
bool pressed = (digitalRead(buttonPin) == LOW);
if (!pressed) {
// button NOT pressed ⇒ blink
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
}
else {
// button pressed ⇒ LED constantly on
digitalWrite(ledPin, HIGH);
}
}