Norway
Offline
Newbie
Karma: 0
Posts: 8
Arduino rocks
|
 |
« on: December 18, 2011, 04:29:17 am » |
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
God Member
Karma: 3
Posts: 513
Have you had your Arduino fix today?
|
 |
« Reply #1 on: December 18, 2011, 05:07:06 am » |
What errors are you getting? Cut and Paste them here
|
|
|
|
|
Logged
|
|
|
|
|
Norway
Offline
Newbie
Karma: 0
Posts: 8
Arduino rocks
|
 |
« Reply #2 on: December 18, 2011, 06:39:25 am » |
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
God Member
Karma: 3
Posts: 513
Have you had your Arduino fix today?
|
 |
« Reply #3 on: December 18, 2011, 06:43:19 am » |
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
|
|
|
|
|
Norway
Offline
Newbie
Karma: 0
Posts: 8
Arduino rocks
|
 |
« Reply #4 on: December 18, 2011, 08:48:30 am » |
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
God Member
Karma: 3
Posts: 513
Have you had your Arduino fix today?
|
 |
« Reply #5 on: December 18, 2011, 09:31:46 am » |
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
|
|
|
|
|
Norway
Offline
Newbie
Karma: 0
Posts: 8
Arduino rocks
|
 |
« Reply #6 on: December 18, 2011, 01:21:40 pm » |
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
God Member
Karma: 3
Posts: 513
Have you had your Arduino fix today?
|
 |
« Reply #7 on: December 18, 2011, 02:53:06 pm » |
My Bad !!!!!
Create WProgram.h
#include <Arduino.h>
Got it back to front - So Sorry
|
|
|
|
|
Logged
|
|
|
|
|
Norway
Offline
Newbie
Karma: 0
Posts: 8
Arduino rocks
|
 |
« Reply #8 on: December 18, 2011, 03:53:10 pm » |
Thank you spycatcher2k! Great. It works!!!
|
|
|
|
« Last Edit: December 19, 2011, 02:34:22 am by Jolv »
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 5
|
 |
« Reply #9 on: March 06, 2012, 09:45:27 am » |
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
|
|
|
|
|
|