#include <stdio.h>
#include "pico/stdlib.h"
#define LED_PIN 2 // LED connected to GPIO 2
int main() {
stdio_init_all(); // Initialize the serial communication (used for the serial monitor)
gpio_init(LED_PIN); // Initialize LED pin (GPIO 2)
gpio_set_dir(LED_PIN, GPIO_OUT); // Set LED pin as output
int blink_count = 10; // Starting with 10 blinks in the first minute
int minute_count = 0; // To track the minute changes
while (true) {
// Print which minute it is and how many times the LED will blink
if (minute_count == 0) {
printf("1st Minute: LED will blink %d times\n", blink_count);
} else if (minute_count == 1) {
printf("2nd Minute: LED will blink %d times\n", blink_count);
} else if (minute_count == 2) {
printf("3rd Minute: LED will blink %d times\n", blink_count);
}
// Blink LED for the defined number of times
for (int i = 0; i < blink_count; i++) {
gpio_put(LED_PIN, 1); // Turn the LED on
printf("Blink %d\n", i + 1); // Print the current blink count to serial monitor
sleep_ms(1000); // Wait for 1000ms
gpio_put(LED_PIN, 0); // Turn the LED off
sleep_ms(1000); // Wait for 1000ms
}
// After finishing blinks for the current minute, print a message
printf("Completed %d blinks in this minute\n", blink_count);
// Update blink count for the next minute
minute_count++;
if (minute_count == 1) {
blink_count = 20; // Second minute: blink 20 times
} else if (minute_count == 2) {
blink_count = 30; // Third minute: blink 30 times
}
// Wait until the next minute before starting the next cycle of blinks
sleep_ms(60000); // Wait for 60 seconds (1 minute)
// Reset the minute counter after the 3rd minute
if (minute_count == 3) {
minute_count = 0;
blink_count = 10; // Start again with 10 blinks in the first minute
}
}
return 0;
}