Pages: [1] 2   Go Down
Author Topic: Using TimeAlarm library to trigger blink at a certain time  (Read 2905 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 637
Posts: 50300
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 637
Posts: 50300
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4092
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

* TimeAlarms.cpp (12.8 KB - downloaded 106 times.)
Logged

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

Pensacola FL
Offline Offline
Jr. Member
**
Karma: 2
Posts: 68
"I've forgotten more than I care to remember!" Capt. Jack Grass
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.  smiley-mad
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4092
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

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

Pensacola FL
Offline Offline
Jr. Member
**
Karma: 2
Posts: 68
"I've forgotten more than I care to remember!" Capt. Jack Grass
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4092
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: August 19, 2012, 08:34:26 pm by Jack Christensen » Logged

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

Pensacola FL
Offline Offline
Jr. Member
**
Karma: 2
Posts: 68
"I've forgotten more than I care to remember!" Capt. Jack Grass
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4092
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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

Pensacola FL
Offline Offline
Jr. Member
**
Karma: 2
Posts: 68
"I've forgotten more than I care to remember!" Capt. Jack Grass
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4092
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey Mark,

Cool! Yeah with Windoze involved we'll cut ya some slack smiley-grin

Have fun ... jc
Logged

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

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4092
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

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

Pages: [1] 2   Go Up
Jump to: