Hi,
I am working on a code to create a moving clock system. I have an RTC1302 to keep the time and the plan is to use that time keeping system to move servo motors at designated times.
I don't have much experience with Arduino code yet, but attached is what I currently have sketch_feb24a.ino (5.0 KB)
.
The top section of the code is the virtuabotixRTC program which did not show up in the possible library downloads so I just found it online. If anyone has any help regarding how to fix these errors I will be very grateful.
if you follow instruction on youtube then follow it to the end.
#include <virtuabotixRTC.h>
// Creation of the Real Time Clock Object
virtuabotixRTC myRTC(6, 7, 8);
void setup() {
Serial.begin(9600);
// Set the current date, and time in the following format:
// seconds, minutes, hours, day of the week, day of the month, month, year
myRTC.setDS1302Time(18, 10, 10, 7, 18, 9, 2020);
}
void loop() {
// This allows for the update of variables for time or accessing the individual elements.
myRTC.updateTime();
// Start printing elements as individuals
Serial.print("Current Date / Time: ");
Serial.print(myRTC.dayofmonth);
Serial.print("/");
Serial.print(myRTC.month);
Serial.print("/");
Serial.print(myRTC.year);
Serial.print(" ");
Serial.print(myRTC.hours);
Serial.print(":");
Serial.print(myRTC.minutes);
Serial.print(":");
Serial.println(myRTC.seconds);
// Delay so the program doesn't print non-stop
delay(500);
}
#include <virtuabotixRTC.h>
virtuabotixRTC myRTC(6, 7, 8);
#include <Servo.h>
Servo servo1; //define test servo
void setup() {
Serial.begin(9600);
servo1.attach(3); //attach servo to pin 3
// myRTC.setDS1302Time(00, 28, 21, 4, 24, 2, 2022); //set the current time
}
void loop() {
myRTC.updateTime();
Serial.print(myRTC.minutes);
Serial.print(":");
Serial.print(myRTC.seconds); //prints the minutes and seconds on serial monitor for checks
if ((myRTC.seconds) == 10);
servo1.write(180); //when seconds hit 10 the servo moves by 180*
if ((myRTC.seconds) == 20);
servo1.write(0); //when seconds hit 20 the servo moves back to start position
delay(5000);
}
here yor programm without unnesecery text. not forget to install the lib from github.