OK so i have a frustrating problem. I have over the past few years made several clocks. However as i attempt to make another clock for a friend i found the sketch no longer works. I have to be honest my programming ability isn't great and no matter how hard i search for an answer i just go around in circles.
Basically i get the following error, and i really don't know why or what has changed to cause it?
It all relates to this code? It used to work now it doesn't??
#include <Wire.h>
#include <Time.h>
#include <DS1307RTC.h>
int i = 0;
int k = 0;
int x = 0;
int minFivesMSB = 0;
int minFivesLSB = 0;
int temp = 0;
int minFives = 0;
int hours = 0;
int hoursFives = 0;
int minUnits = 0;
int oldHoursFives = hoursFives;
const int changeTime = 14;
const int setHourPos = 15;
const int setMinPos = 16;
const int setHourNeg = 17;
const int setMinNeg = 11;
tmElements_t tm;
In file included from C:\Users\Martin\Documents\Arduino\ring_clock\ring_clock.ino:3:0:
C:\Users\Martin\Documents\Arduino\libraries\DS1307RTC/DS1307RTC.h:19:22: error: 'tmElements_t' has not been declared
static bool read(tmElements_t &tm);
^~~~~~~~~~~~
C:\Users\Martin\Documents\Arduino\libraries\DS1307RTC/DS1307RTC.h:20:23: error: 'tmElements_t' has not been declared
static bool write(tmElements_t &tm);
^~~~~~~~~~~~
ring_clock:20:1: error: 'tmElements_t' does not name a type
tmElements_t tm;
^~~~~~~~~~~~
C:\Users\Martin\Documents\Arduino\ring_clock\ring_clock.ino: In function 'void checkAdj()':
ring_clock:86:12: error: expected primary-expression before '.' token
i = (tm.Minute);
^
ring_clock:87:12: error: expected primary-expression before '.' token
k = (tm.Hour);
^
C:\Users\Martin\Documents\Arduino\ring_clock\ring_clock.ino: In function 'void loop()':
ring_clock:95:3: error: 'tmElements_t' was not declared in this scope
tmElements_t = tm;
^~~~~~~~~~~~
ring_clock:95:20: error: expected primary-expression before ';' token
tmElements_t = tm;
^
ring_clock:96:18: error: expected primary-expression before ')' token
if (RTC.read(tm))
^
ring_clock:99:12: error: expected primary-expression before '.' token
i = (tm.Minute);
^
ring_clock:100:12: error: expected primary-expression before '.' token
k = (tm.Hour);
^
exit status 1
'tmElements_t' does not name a type
Thanks for your quick reply's, my searches found this solution but it doesn't work for me? I get the following message
ring_clock:2:10: fatal error: TimeLib.h: No such file or directory #include <TimeLib.h>
Thanks for your reply, I have managed to get the new Library. I found it very frustrating trying to work out why my code which is working in a clock i made a few years ago, would no longer work?
Thanks for your help.
mr_fid:
Thanks for your reply, I have managed to get the new Library. I found it very frustrating trying to work out why my code which is working in a clock i made a few years ago, would no longer work?
Thanks for your help.
One thing you can do, is package all your code along with a snapshot copy of any libraries that you used, in a project folder somewhere on your file tree other than the Arduino directories. Keep it as an archive for when you need to recompile it later. Embed notes about which version you compiled it under, along with any hardware information that's relevant.
Your sketch (given below) is compiled well under the inclusion of the attached Libraries @PaulStoffregen.
#include <Wire.h>
#include <Time.h>
#include <DS1307RTC.h>
int i = 0;
int k = 0;
int x = 0;
int minFivesMSB = 0;
int minFivesLSB = 0;
int temp = 0;
int minFives = 0;
int hours = 0;
int hoursFives = 0;
int minUnits = 0;
int oldHoursFives = hoursFives;
const int changeTime = 14;
const int setHourPos = 15;
const int setMinPos = 16;
const int setHourNeg = 17;
const int setMinNeg = 11;
tmElements_t tm;
void setup()
{
}
void loop()
{
}