// Button-Activated LED Blinker
const int buttonPin = 3; // Push Button Pin
const int ledPin = 9; // LED Pin
void setup() {
pinMode(buttonPin, INPUT); // Let Green push button be the input
pinMode(ledPin, OUTPUT); // Let Yellow LED pin be the output
Serial.begin(9600); // Start of serial communication
}
void loop() {
// Read the state of the push button
int buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
// When button is pressed, the LED starts blinking
digitalWrite(ledPin, HIGH);
Serial.println("Blinking");
// Added button press command due to inconsistency in LED blinking during push button tests
Serial.println("Button Pressed");
delay(100); // LED ON duration
digitalWrite(ledPin, LOW);
delay(100); // LED OFF duration
} else {
// Button is not pressed, stop blinking
digitalWrite(ledPin, LOW);
Serial.println("Stopped");
Serial.println("Button Released");
delay(200); // Small delay to avoid flooding the Serial Monitor
}
}