I'm encountering some issues on the displaying of time in my rtc ds1302, it shows a null data between one second of each time.
#include <DS1302.h> //instead of parenthesis () put angle bracket as YouTube description does not allow angle bracket
#include <Servo.h>
Time time;
Servo myservo;
int Hour;
int Minute;
int Second;
// Init the DS1302
DS1302 rtc(2, 4, 5);
void setup()
{
myservo.attach(7);
myservo.write(45);
Serial.println();
// Set the clock to run-mode, and disable the write protection
rtc.halt(true);
rtc.writeProtect(false);
Serial.begin(9600);
// The following lines can be commented out to use the values already stored in the DS1302
rtc.setDOW(SUNDAY); // Set Day-of-Week to SUNDAY
rtc.setTime(1, 33, 00); // Set the time to 12:00:00 (24hr format)
rtc.setDate(4, 21, 2024); // Set the date to August 25th, 2019
}
void loop()
{
time = rtc.getTime();
Hour = time.hour;
Minute = time.min;
Second = time.sec;
Serial.print(Hour);
Serial.print(":");
Serial.print(Minute);
Serial.print(":");
Serial.println(Second);
Serial.print(rtc.getDateStr(FORMAT_SHORT, FORMAT_LITTLEENDIAN, '/'));
delay(1000);
//set the time for fish feeding
if ((Hour== 1 && Minute== 33 && Second== 11)||(Hour== 1 && Minute== 34 && Second== 13)) {
myservo.write(0);
delay (300);
myservo.write(45);
delay (300);}
}