// Define the LED pin
const int ledPin = 13;
// Define the starting countdown time in seconds
int countdownTime = 5; // 60 seconds
void setup() {
// Initialize the LED pin as an output
pinMode(ledPin, OUTPUT);
// Start serial communication for debugging
Serial.begin(9600);
}
void loop() {
// Check if countdownTime is greater than 0
if (countdownTime > 0) {
// Print the countdown value to the Serial Monitor
Serial.print("Time remaining: ");
Serial.println(countdownTime);
// Decrease the countdown value by 1
countdownTime = countdownTime - 1;
// Wait for 1 second before continuing the countdown
delay(1000); // Delay for 1000 milliseconds (1 second)
}
else {
// Once countdown reaches 0, turn on the LED
digitalWrite(ledPin, HIGH);
// Print a message indicating the LED is on
Serial.println("Countdown complete! LED ON.");
delay
// Optionally, you can stop the countdown after it reaches 0
// To restart the countdown, you can reset countdownTime or press the reset button.
// delay(5000); // Add delay if you want to hold the LED on for 5 seconds
}
}