Playing with TimeAlarms and need help :)

Hey all, I’m a total noob with very little programming knowledge, but i’m working everyday to fix that. I have been playing for the last couple days on some small easy stuff and i’m now playing with the TimeAlarm, but can’t get my very simple code to work. Is any one able to look at this and tell me if it should work? Thanks

It does debug and flash correctly, I just cant see the led flash. I’m guessing it may have to do with time zone but i’m not sure.

// This #include statement was automatically added by the Spark IDE.

#include "TimeAlarms/TimeAlarms.h"

int led = D1; // This one is the built-in tiny one to the right of the USB jack

void setup() 
{; // UTC time -5 for central time 
  Alarm.alarmRepeat(8,31,0, BlinkledAlarm); //Testing first alarm at 8.31 am.. Blinkledalarm is the   name of the alarm 
  pinMode(led, OUTPUT);

// Very simple blink function 

void BlinkledAlarm() {
  digitalWrite(led, HIGH);
  delay(1000); // Turn ON the LED pins
  digitalWrite(led, LOW);
  delay(5000); // Turn OFF the LED pins
  digitalWrite(led, HIGH);
  delay(1000); // Turn ON the LED pins

@speedgoofy, you are missing the loop() function in which you need to call Alarm.delay() in order for the Alarm code to “run”:

void  loop(){  
  Alarm.delay(1000); // wait one second & update the alarms



@peekay123 Thanks I really appreciate the response! At the top in the TimeAlarmsExample.ino it says “At startup the time is set to Jan 1 2011 8:29 am” so i put 8.31 am in thinking it will flash in 2 minutes after i flash the core, is this thinking correct? Is there reading or instructions page for these libraries that i’m missing ?

First things first: the tiny LED is actually D7. If set to D1, you can wait for a very long time :wink:
I’m not sure about the explanation of the code. If your time zone is set correctly (which you can check by having it output the current time through Serial, as mentioned in the example), than you can just set the time you like.
If you want the function to be run at 9:30, you should just put 9,30,0. It’s not relative to the programming time. It gets the actual time, so that’s what you should be using as well.
Good luck!


hahaha @Moors7 wow can’t believe i missed that, it worked :smiley:

1 Like