Hi,
I am trying to make an alarm clock using an arduino nano and an adafruit ds3231 rtc (Product # 3013) and I am getting the following error (lines 49-54) when I request the Date and Time info from the rtc and try to put the aquired values into integers for later use:
cannot convert 'DateTime::year' from type 'uint16_t (DateTime::)() const {aka unsigned int (DateTime::)() const}' to type 'int'
How can I convert and the Date and Time info into intergers so that I can use them more easily later?
Alarm_Clock.ino (1.55 KB)
Code posted properly, as described in "How to use this forum".
Post a link to where you downloaded the RTC library, and while you are at it, you might take a look at the library documentation, for hints on how to use it.
// link neccessary libraries for screen and real-time clock
#include <RTClib.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>
#include <gfxfont.h>
#include <Adafruit_LEDBackpack.h>
// define pins and asociated variables
const int DATA = A0; // Shift DATA pin
const int CLOCK = A1; // Shift CLOCK pin
const int LATCH = A2; // Shift LATCH pin
byte InByte1; // Shift 1st byte
byte InByte2; // Shift 2nd byte
const int ALARM = 6; // Alarm signal output
const int SET = 11; // Set input button
RTC_DS3231 rtc; // real-time clock module
Adafruit_AlphaNum4 Display = Adafruit_AlphaNum4(); // 4 digit LED display
int Year; // Year variable
int Y1; //
int Y2;
int Y3;
int Y4;
int Month;
int Mo1;
int Mo2;
int Day;
int D1;
int D2;
int DOW;
int Hour;
int H1;
int H2;
int Minute;
int Mi1;
int Mi2;
int AMin;
int AHour;
void setup() {
// setup pins.
pinMode(DATA, INPUT);
pinMode(CLOCK, OUTPUT);
pinMode(LATCH, OUTPUT);
pinMode(ALARM, OUTPUT);
pinMode(SET, INPUT);
// Aquire time from RTC
DateTime now = rtc.now();
Year = now.year;
Month = now.month;
Day = now.day;
DOW = now.dayOfTheWeek;
Hour = now.hour;
Minute = now.minute;
// Check for time change request
digitalWrite(LATCH, HIGH);
delayMicroseconds(20);
digitalWrite(LATCH, LOW);
InByte1 = shiftIn(DATA, CLOCK, MSB);
InByte2 = shiftIn(DATA, CLOCK, MSB);
if (InByte1 == 0 && InByte2 == 0){
}
else if (InByte1 == 0 && InByte == 1){
}
}
void loop() {
// put your main code here, to run repeatedly:
}
Year = now.year;
I could be wrong, but I'm guessing that you're missing a pair of parentheses.
Try this instead:
Year = now.year();
and likewise for the month, etc.
Thanks. turns out it was missing parentheses that was the problem.