Go Down

Topic: Using TimeAlarm library to trigger blink at a certain time (Read 3266 times) previous topic - next topic

Hi, this is my first step into Arduino and micro controllers. I do have C# experience, but the Arduino code is kind of throwing me of. Anyway, I want my arduino to trigger blink at a specific time. Here is my code:
Code: [Select]

#include <Time.h>
#include <TimeAlarms.h>
int led = 2;

void setup()
{
  Serial.begin(9600);
  setTime(9,15,0,8,11,12); // set time to Saturday 8:29:00am Jan 1 2011
  Alarm.alarmRepeat(5, 45, 0, MorningAlarm);
  pinMode(led, OUTPUT);

}


void MorningAlarm()
{
Serial.println("Wake UP");
digitalWrite (led, HIGH); 
delay(1000);
digitalWrite (led, LOW);
delay(1000);
}


I get this error message:
C:\Users\John\Desktop\arduino-1.0.1\libraries\TimeAlarms\TimeAlarms.cpp: In member function 'void TimeAlarmsClass::delay(long unsigned int)':
C:\Users\John\Desktop\arduino-1.0.1\libraries\TimeAlarms\TimeAlarms.cpp:256: error: 'millis' was not declared in this scope

What is the problem? I installed the Time library and all the libraries in it. Thanks for helping me out.

PaulS

Let's start with the basics. What version of the IDE are you using? 1.0.1 has a fatal flaw, in my opinion, in which missing include files are not fatal errors.

KlausNZ

Hi, where does one find the TimeAlarms library? Been searching the arduino site but no luck.
Many thanks in advance!

PaulS

Quote
Hi, where does one find the TimeAlarms library? Been searching the arduino site but no luck.


What have you been searching for?

http://arduino.cc/playground/Code/Time

Jack Christensen

Oddly, while the Time library was updated for Arduino 1.0 and later, TimeAlarms was not. Replace the TimeAlarms.cpp file with the one attached.

Your sketch also needs the loop() function defined. Every Arduino sketch needs setup() and loop() defined, even if they are empty.
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Mark_Grass

I've tried the file that Jack Christensen posted, but I still get the following:
C:\arduino-1.0.1\libraries\TimeAlarms\TimeAlarms.cpp: In member function 'void TimeAlarmsClass::delay(long unsigned int)':
C:\arduino-1.0.1\libraries\TimeAlarms\TimeAlarms.cpp:256: error: 'millis' was not declared in this scope.   I'm using the stock unchanged example "TimeAlarmExample".  I'm running 1.0.1.  Getting really frustrated.  :0

Jack Christensen

I just double-checked using the following procedure, also using Arduino 1.0.1.

1. Shut down the IDE.
2. Delete Time, TimeAlarms, DS1307RTC libraries.
3. Download Time.zip from http://arduino.cc/playground/Code/Time and unzip.
4. Start IDE, compile "TimeAlarmExample" ... duplicates the error messages as above.
5. Shut down IDE.
6. Download TimeAlarms.cpp from the post above, replace the existing file in the library with it.
7. Start IDE, compile "TimeAlarmExample" ... compiles OK.

I know that no one likes to hear "NTF" but if I can't duplicate the problem...
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Mark_Grass

Jack,
I'm at a loss.   I took line 256 from TimeAlarms.cpp and put it in a blank sketch with the setup and void loop, and it compiles fine?  I'll have to try it on my laptop and see if I get the same error.    I have started and restarted, deleted and reinstalled on  desktop cpu. and can't get rid of the error.   
Mark

Jack Christensen

#8
Aug 20, 2012, 03:31 am Last Edit: Aug 20, 2012, 03:34 am by Jack Christensen Reason: 1

I took line 256 from TimeAlarms.cpp and put it in a blank sketch with the setup and void loop, and it compiles fine?


Huh? What's on that line, and why would you do that? Line 256 in TimeAlarms.cpp is a blank line in my copy. Did you follow the procedure in my previous post, verbatim?

Edit: Oh sorry, line 256 is blank in my modified version, but not in the original. Anyway, I don't see where doing that is appropriate, so same answer, follow the procedure above. Delete the libraries, download an install fresh copies, then replace the TimeAlarms.cpp file with my modified version.
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Mark_Grass

Hey Jack,
Tried it on the laptop; same thing.
The reason that I moved the line to a basic sketch with nothing else was to verify that millis() is defined.   I'm going to do a complete new install of the ide and libs. 

Mark

Jack Christensen

Ah, ok, so millis() works in other circumstances. Any chance that the new version of TimeAlarms.cpp is not getting saved in the right place? If line 256 was not blank, then that's not my updated copy. There could be other things I suppose, but those symptoms are consistent with the original TimeAlarms.cpp from the zip file being used.
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Mark_Grass

Hi Jack,
Did a complete install of the ide and the time lib, along with the updated file from you.
It now works.   Not sure what was wrong (probably me....I mean most likely me.  We know it couldn't be Windows).   
Now I need to load my other libs one at a time and make sure that it doesn't corrupt anything.   

Thanks,  Mark

Jack Christensen

Hey Mark,

Cool! Yeah with Windoze involved we'll cut ya some slack :D

Have fun ... jc
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Gh3kko

can you post/share the updated file? I have the same issue re install did not work for me, tested on 2 machines.

thanks

Jasper


Jack Christensen


can you post/share the updated file? I have the same issue re install did not work for me, tested on 2 machines.

thanks

Jasper


Look up ... it's still there:
http://arduino.cc/forum/index.php/topic,118132.msg890823.html#msg890823
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Go Up