DS1302 alternating null data

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);}
}

With the code you it takes the 1302 around 700mS to reply with the time, if you look faster that might be your issue .
There is other code you can use that’s not held up by the 1302 .
Google non blocking 1302.

Another thought is how are the servos powered ? Not from the Arduino I hope ….

Error compiling.

Is something missing, or what is the link to your DS1302.h library

The library came from the Arduino itself. It compiles well in my part but the problem is coming from output of my rtc

Can you elaborate more? The servo is connected to arduino uno

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.