I have used a couple of sources to come up with some code.... The problem that I have run into is that the code wont compile. The error message I keep getting is....
Arduino: 1.8.2 (Windows 8.1), Board: "Arduino Leonardo"
Build options changed, rebuilding all
Servo_and_RTC_code:3: error: no matching function for call to 'DS3231::DS3231(const uint8_t&, const uint8_t&)'
DS3231 rtc(SDA, SCL);
^
C:\Users\Ed\Documents\Servo_and_RTC_code\Servo_and_RTC_code.ino:3:20: note: candidates are:
In file included from C:\Users\Ed\Documents\Servo_and_RTC_code\Servo_and_RTC_code.ino:1:0:
C:\Users\Ed\Documents\Arduino\libraries\DS3231/DS3231.h:64:3: note: DS3231::DS3231()
DS3231();
^
C:\Users\Ed\Documents\Arduino\libraries\DS3231/DS3231.h:64:3: note: candidate expects 0 arguments, 2 provided
C:\Users\Ed\Documents\Arduino\libraries\DS3231/DS3231.h:60:7: note: constexpr DS3231::DS3231(const DS3231&)
class DS3231 {
^
C:\Users\Ed\Documents\Arduino\libraries\DS3231/DS3231.h:60:7: note: candidate expects 1 argument, 2 provided
C:\Users\Ed\Documents\Arduino\libraries\DS3231/DS3231.h:60:7: note: constexpr DS3231::DS3231(DS3231&&)
C:\Users\Ed\Documents\Arduino\libraries\DS3231/DS3231.h:60:7: note: candidate expects 1 argument, 2 provided
Servo_and_RTC_code:4: error: 'Time' does not name a type
Time t; //define a name for the time function
^
C:\Users\Ed\Documents\Servo_and_RTC_code\Servo_and_RTC_code.ino: In function 'void setup()':
Servo_and_RTC_code:15: error: 'class DS3231' has no member named 'begin'
rtc.begin();
^
C:\Users\Ed\Documents\Servo_and_RTC_code\Servo_and_RTC_code.ino: In function 'void loop()':
Servo_and_RTC_code:21: error: 't' was not declared in this scope
t = rtc.getTime();
^
Servo_and_RTC_code:21: error: 'class DS3231' has no member named 'getTime'
t = rtc.getTime();
^
Servo_and_RTC_code:29: error: 'OnHOur' was not declared in this scope
if (t.hour == OnHOur && t.min == OnMin {
^
Servo_and_RTC_code:29: error: expected ')' before '{' token
if (t.hour == OnHOur && t.min == OnMin {
^
Servo_and_RTC_code:43: error: expected primary-expression before '}' token
}
^
exit status 1
no matching function for call to 'DS3231::DS3231(const uint8_t&, const uint8_t&)'
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
This is the code I have so far
#include <DS3231.h>
#include <Servo.h>
DS3231 rtc(SDA, SCL);
Time t; //define a name for the time function
//The start and end times of the desired operation
const int OnHour = 12;
const int OnMin = 24;
const int OffHour = 12;
const int OffMin = 25;
Servo myservo; //create servo object to control a servo..... a maximum of 8 servos can be created
int pos = 0; //variable to store the servo position
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
rtc.begin();
myservo.attach(9); //attaches the servo on pin 9 to the servo object
}
void loop() {
// put your main code here, to run repeatedly:
t = rtc.getTime();
Serial.print(t.hour);
Serial.print (" hour(s),");
Serial.print (t.min);
Serial.print (" minute(s)");
Serial.println(" ");
delay (1000);
if (t.hour == OnHOur && t.min == OnMin {
for (pos = 0; pos < 180; pos += 1) //goes from 0 degrees to 180 degrees
{
myservo.write(pos); //tell servo to go to position in variable 'pos'
delay(3); // wait 3ms for the servo to reach the position
}
{
for (pos = 180; pos >= 1; pos -= 1)
{
myservo.write(pos); //tell servo to go to position in variable pos
delay(3); //wait 3ms for the servo to reach the position
}
}
}
}