#include <DS1302.h>
#include <Servo.h>
Time t;
Servo myservo;
int Hour;
int Min;
int Sec;
// Init the DS1302
DS1302 rtc(2, 3, 4);

void setup()
// Set the clock to run-mode, and disable the write protection
// 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(8, 59, 50); // Set the time to 12:00:00 (24hr format)
//rtc.setDate(8, 25, 2019); // Set the date to August 25th, 2019

void loop()
t = rtc.getTime();
Hour = t.hour;
Min = t.min;
Sec = t.sec;

//set the time for fish feeding 
if ((Hour== 2 && Min== 0 && Sec== 2)||(Hour== 21 && Min== 0 && Sec== 2)) {
delay (300);
delay (300);}
  • 1
    Nope, nothing seems to work hahaha – Tiago Kotryk Sep 13 at 5:14
  • 2
    You need to define "doesn't work". What output are you expecting? What output do you get? What happens? It's like going to a doctor and saying you feel sick. S/he needs more details than that. – Nick Gammon Sep 13 at 6:08
  • 1
    Serial.begin(9200) ? and depending on the library, the rtc.get time may get stuck in a bad connection to the rtc chip. – Tirdad Sadri Nejad Sep 13 at 6:42
  • 1
    @st2000 I think that the only thing I didn't cover so far is if the correct pins are being used. How do I check that? – Tiago Kotryk Sep 13 at 14:16
  • 3
    Does this answer your question? Code for fish auto feeder not working – Delta_G Sep 13 at 14:24

I think the problem is that you have given the baud rate as 9200 but the minimum baud rate is 9600(Serial.begin(9600)). And change the baud rate in the serial monitor.

| improve this answer | |
  • 1
    4 hours before you posted your answer, Tiago Kotryk already replied in the comments that changing the baud rate to 9600 didn't make a difference. So why post this as an answer? – StarCat Sep 13 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.