#include "pico/stdlib.h"
volatile bool timer_fired = false;
int64_t alarm_callback(alarm_id_t id, void *user_data) {
timer_fired = true;
// Can return a value here in us to fire in the future
return 0;
}
int main() {
stdio_init_all();
// Call alarm_callback in 300 ms
if (!add_alarm_in_ms(300, alarm_callback, NULL, false)) {
printf("Failed to add timer\n");
}
while(1){
if(timer_fired){
timer_fired = 0;
printf("Hello from alarm!");
}
}
}