#define LED_PIN 25 // Define onboard LED pin
#define BUTTON_PIN 2 // Define button GPIO pin
bool reverse_mode = false; // Toggle for reverse mode
void blink_led(int blinks, int duration_ms) {
int interval = duration_ms / (2 * blinks); // Calculate time for each ON/OFF
for (int i = 0; i < blinks; i++) {
digitalWrite(LED_PIN, HIGH); // Turn LED on
delay(interval);
digitalWrite(LED_PIN, LOW); // Turn LED off
delay(interval);
}
}
void setup() {
pinMode(LED_PIN, OUTPUT); // Set LED_PIN as output
pinMode(BUTTON_PIN, INPUT_PULLUP); // Set BUTTON_PIN as input with pull-up resistor
}
void loop() {
// Check if button is pressed (active LOW)
if (digitalRead(BUTTON_PIN) == LOW) {
reverse_mode = !reverse_mode; // Toggle mode
delay(300); // Debounce delay
}
if (!reverse_mode) {
// Normal sequence
blink_led(10, 60000); // Blink 10 times in the first minute
blink_led(20, 60000); // Blink 20 times in the second minute
blink_led(30, 60000); // Blink 30 times in the third minute
} else {
// Reverse sequence
blink_led(30, 60000); // Blink 30 times in the first minute
blink_led(20, 60000); // Blink 20 times in the second minute
blink_led(10, 60000); // Blink 10 times in the third minute
}
}