Pages: [1]   Go Down
Author Topic: Arduino 1: Problem with Alarm.delay ?  (Read 1119 times)
0 Members and 1 Guest are viewing this topic.
Norway
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am trying to upgrade a sketch to Arduino 1, but get compilation errors.
A few of the  lines which seems to create  problems have been extracted and is listed below.
(Obviously no need for Alarm.delay(3000) here, but it examples my problem.)
Can anybody give advice? Thank you.
   -   -   -   -   -   -   -   -   -   -
#include <SoftwareSerial.h>
#include <Time.h>
#include <TimeAlarms.h>

void setup()   {
  Serial.begin(9600);
}
void loop()    {
  Alarm.delay(3000);  // <<  Cause problem (?)
  Serial.print("sec= ");
  Serial.println(second());
// . . .
}

=============================================
The solution, provided by Spycatcher2K, is:

goto >      C:\Program Files\arduino-1.0\hardware\arduino\cores\arduino
Create a file called WProgram.h
and in it type :
#include <Arduino.h>

save and restart your IDE
« Last Edit: December 18, 2011, 04:02:32 pm by Jolv » Logged

Scotland
Offline Offline
Edison Member
*
Karma: 24
Posts: 1243
Have you had your Arduino fix today?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What errors are you getting? Cut and Paste them here
Logged

Drew.
http://www.uk-pcb.co.uk - My UK Based PCB Fab & Assembly Company
Design work undertaken
SMD & Thru-Hole assembly

Norway
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I get these error messages:
C:\Program Files\arduino-1.0\libraries\Time\Time.cpp:24:23: error: WProgram.h: No such file or directory
C:\Program Files\arduino-1.0\libraries\Time\Time.cpp: In function 'time_t now()':
C:\Program Files\arduino-1.0\libraries\Time\Time.cpp:240: error: 'millis' was not declared in this scope
C:\Program Files\arduino-1.0\libraries\Time\Time.cpp: In function 'void setTime(time_t)':
C:\Program Files\arduino-1.0\libraries\Time\Time.cpp:268: error: 'millis' was not declared in this scope
- - - - - -
It har probably somthing to do with Arduino 1, Release note:
* The WProgram.h file, which provides declarations for the Arduino API,
  has been renamed to Arduino.h. To create a library that will work in
  both Arduino 0022 and Arduino 1.0, you can use an #ifdef that checks
  for the ARDUINO constant, which was 22 and is now 100.  For example:
  ...

It is probably absolutely trivial for an experienced user to find the WProgram.h files and copy them them into the library, but I have not been able to do so even after a lot of searching.
« Last Edit: December 18, 2011, 06:45:14 am by Jolv » Logged

Scotland
Offline Offline
Edison Member
*
Karma: 24
Posts: 1243
Have you had your Arduino fix today?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

goto >      C:\Program Files\arduino-1.0\hardware\arduino\cores\arduino


Create a file called Arduino.h

and in it type :

#include <WProgram.h>

save and restart your IDE

See if this helps.
« Last Edit: December 18, 2011, 07:38:42 am by spycatcher2k » Logged

Drew.
http://www.uk-pcb.co.uk - My UK Based PCB Fab & Assembly Company
Design work undertaken
SMD & Thru-Hole assembly

Norway
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry, no success.

I tried to follow your advice, but got a bunch of new errors (perhaps I did a mistake).
I also compaired ...\cores\arduino for .0023 and 1., and found that 1. does not include WProgram.h. I tried to include WProgram.h in ...\cores\arduino for 1., but it did not help.

I suppose I am to unexperienced with this type of programing to handle this problem. Do not understand properly what I am doing. -  After all .0023 does a fine job for me, and I will stick with it for now.

Thank you very much, spycatcher2k, for your advice.
Logged

Scotland
Offline Offline
Edison Member
*
Karma: 24
Posts: 1243
Have you had your Arduino fix today?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I just compiled your code with IDE 1.0 with no errors
When you created the file and contents, did you make sure to match CASE as they are CASE SENSATIVE.
Logged

Drew.
http://www.uk-pcb.co.uk - My UK Based PCB Fab & Assembly Company
Design work undertaken
SMD & Thru-Hole assembly

Norway
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks again!  I hate to give up, and a solution cannot be very far away since it compiles on your computer. Where do I go wrong?? -  A have reinstalled Arduino-1.0 and new copies Time.h and TimeAlarms.h

In   C:\Program Files\arduino-1.0\hardware\arduino\cores\arduino
it is already a file called Arduino.h,  so I am confused. Should I really make another file with the same name? (In fact I have tried to do that also, but with 0 success).

I have also simplified my sketch down to:

#include <SoftwareSerial.h>
#include <Time.h>
#include <TimeAlarms.h>
void setup()   { }
void loop()    { }

If I comment out #include <TimeAlarms.h> it compiles OK. If I don't  I get these error message:

C:\Program Files\arduino-1.0\libraries\TimeAlarms\TimeAlarms.cpp:25:22: error: WProgram.h: No such file or directory
C:\Program Files\arduino-1.0\libraries\TimeAlarms\TimeAlarms.cpp: In member function 'void TimeAlarmsClass::delay(long unsigned int)':
C:\Program Files\arduino-1.0\libraries\TimeAlarms\TimeAlarms.cpp:256: error: 'millis' was not declared in this scope

« Last Edit: December 18, 2011, 01:33:29 pm by Jolv » Logged

Scotland
Offline Offline
Edison Member
*
Karma: 24
Posts: 1243
Have you had your Arduino fix today?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

My Bad !!!!!

Create WProgram.h

#include <Arduino.h>

Got it back to front - So Sorry
Logged

Drew.
http://www.uk-pcb.co.uk - My UK Based PCB Fab & Assembly Company
Design work undertaken
SMD & Thru-Hole assembly

Norway
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you spycatcher2k! Great.    It works!!!
« Last Edit: December 19, 2011, 02:34:22 am by Jolv » Logged

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

I got the same problem but this solution didn't worked for me.

So instead of creating the file WProgram.h, I edited the file TimeAlarms.cpp (you can find it in the library directory) and then changed the following 

#include <WProgram.h>  by   #include <Arduino.h>

So I finally got (extract of the file)


<<extern "C" {
#include <string.h> // for memset
}

#include <Arduino.h>
#include "TimeAlarms.h"
#include "Time.h"

#define IS_ONESHOT  true   // constants used in arguments to create method
#define IS_REPEAT   false


//**************************************************************
//* Alarm Class Constructor >>
Logged

Pages: [1]   Go Up
Jump to: