Hi all!
This is my first post to the forum, I have generally ben able to work bits ot looking threw other threads and questions, but this simple little issue has me stumped..
Project end result wanted (not yet): Aquarium light dimmer. fade lights on/off over 2 hour periods.
eg:
start fading in at 7.30am : full brightness by 9.30am
start fade out at 5.30pm : fully off by 7.30pm
So far: already fading LEDs threw a constant current driver, using the PWM from the Uno, but now I would like to get the timing into the sketch.
(I have a main sketch that makes the aquarium lights fade on then off then on then off etc.. continuously - for practice - I just want to learn the RTC in a new sketch to work out its functionality and commands before I integrate it into the main sketch)
So all my question is = when trying to serial print the time from the rtc continuously, I get this error:
Using library Time in folder: C:\Users\daniel\Documents\Arduino\libraries\Time
Using library I2C in folder: C:\Users\daniel\Documents\Arduino\libraries\I2C (legacy)
Using library RTC in folder: C:\Users\daniel\Documents\Arduino\libraries\RTC (legacy)
E:\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IE:\Arduino\hardware\arduino\avr\cores\arduino -IE:\Arduino\hardware\arduino\avr\variants\standard -IC:\Users\daniel\Documents\Arduino\libraries\Time -IC:\Users\daniel\Documents\Arduino\libraries\I2C -IC:\Users\daniel\Documents\Arduino\libraries\RTC C:\Users\daniel\AppData\Local\Temp\build124847697314085918.tmp\practicing_RTC.cpp -o C:\Users\daniel\AppData\Local\Temp\build124847697314085918.tmp\practicing_RTC.cpp.o
In file included from practicing_RTC.ino:1:0:
C:\Users\daniel\Documents\Arduino\libraries\RTC/RTC.h:99:32: error: expected unqualified-id before 'const'
static DayOfWeek dayOfWeek(const RTCDate *date);
^
C:\Users\daniel\Documents\Arduino\libraries\Time/Time.h:79:32: note: in definition of macro 'dayOfWeek'
#define dayOfWeek(time) ((( time / SECS_PER_DAY + 4) % DAYS_PER_WEEK)+1) // 1 = Sunday
^
C:\Users\daniel\Documents\Arduino\libraries\RTC/RTC.h:99:32: error: expected ')' before 'const'
static DayOfWeek dayOfWeek(const RTCDate *date);
^
C:\Users\daniel\Documents\Arduino\libraries\Time/Time.h:79:32: note: in definition of macro 'dayOfWeek'
#define dayOfWeek(time) ((( time / SECS_PER_DAY + 4) % DAYS_PER_WEEK)+1) // 1 = Sunday
^
C:\Users\daniel\Documents\Arduino\libraries\RTC/RTC.h:99:32: error: expected ')' before 'const'
static DayOfWeek dayOfWeek(const RTCDate *date);
^
C:\Users\daniel\Documents\Arduino\libraries\Time/Time.h:79:32: note: in definition of macro 'dayOfWeek'
#define dayOfWeek(time) ((( time / SECS_PER_DAY + 4) % DAYS_PER_WEEK)+1) // 1 = Sunday
^
C:\Users\daniel\Documents\Arduino\libraries\RTC/RTC.h:99:32: error: expected ')' before 'const'
static DayOfWeek dayOfWeek(const RTCDate *date);
^
C:\Users\daniel\Documents\Arduino\libraries\Time/Time.h:79:32: note: in definition of macro 'dayOfWeek'
#define dayOfWeek(time) ((( time / SECS_PER_DAY + 4) % DAYS_PER_WEEK)+1) // 1 = Sunday
^
practicing_RTC.ino: In function 'void loop()':
practicing_RTC.ino:22:17: error: 'time' was not declared in this scope
'time' was not declared in this scope
MY CODE:
#include <Time.h>
#include <SoftI2C.h>
#include <DS3232RTC.h>
SoftI2C i2c(A4, A5); //Assign pins to the I2C bus (SDA, SCL)
DS3232RTC rtc(i2c);
void setup() {
Serial.begin(9600);
RTCTime time; //setup an instance of time
time.hour = 14;
time.minute = 21;
time.second = 00;
rtc.writeTime(&time); // Set the clock
}
void loop() {
rtc.readTime(&time); // read the time
Serial.print("Time: "); // print the time
Serial.print(time.hour, DEC); // THIS IS THE LINE IT HIGHLITS for the error
Serial.print(':');
Serial.print(time.minute, DEC);
Serial.print(':');
Serial.print(time.second, DEC);
Serial.print('\n');
}