last day (15 days later) » 

08:40
-2
Q: Code for fish auto feeder not working

Tiago KotrykI've been trying to make this code work, but for some reason, it doesn't work for me, even if I do everything like in the tutorial. So I've tried to do a new code and the outcome was the same. The servo doesn't move at all when it is supposed to. this is my code: #include <Servo.h> #include <DS13...

Have you ever set the clock on the DS1302, like the commented-out section after Serial.begin(9600); shows you?
Unrelated. You feeder will open and close 11 times when 9:14 or 21:00. As opening and closing will only take 5.4 seconds, and it will be 9:14 for a whole minute. A slightly intelligent solution would be to add a delay(60000) after the two for loops, so it will open and close only once.
Starcat no, the clock is already set by default. And originaly the code was "Serial.begin(9200)", I changed to "9600"
Gerben, the idea is to open and close just one time, what made you think it would open 11 times?
It will open and close multiple times, as Gerben wrote. At 9:14 you first enter the if clause and move the servo. That takes about 5s. Then you go out of the if clause and the loop() function will loop. That takes very small time. So you again reach the if clause and it is now about 9:14:5. Since you only check the minutes and hours the if condition is still true and the motor moves again. That goes on, until its 9:15
@chrisl Guys, I don't understand much of what you are saying... Is it possible to give your suggestions to make it work rewriting the part of the code you think needs to be rewrite? I only need the servo to move once when the time in the if clause is reached.
08:40
Do you understand that if you move the servo at 9:14 and then recheck the time it is still going to be 9:14? That's all they're telling you.
Have you verified that the servo moves with another simpler code? Have you tried the sweep example for instance? Show your wiring, are you sure you connected it right? Do you have it powered properly?
I just ran the simulation, with only the servo part. It works just fine
OP, please ask the question once and then keep with that thread. You have this same question out here so many times. Why do you keep reposting the same problem with different text?
@Delta_G You are right, I've posted when I had different codes to show. But so far I couldn't make any work
@goodarduinocode Just the servo part is fine, the problem is that I can't make it work with the RTC, as discribed.
@sempaiscuba nope
08:40
So why have you posted the same question multiple times?
@sempaiscuba different codes... None working.
But the same problem. Just put them all in one question.
@sempaiscuba your suggestion has already been made. Do you have a resolution for the issue?
@TiagoKotryk you are like the guy who enters a motorcycle race, and expects to win, even though he can't even ride a bicycle .... back when you started your questions I suggested that you start by only printing "hello" when the seconds were at 10 ... had you done that, you would saved yourself a lot of grief ... you would have discovered that the message prints multiple of times in one second and you would have moved to figuring out how to print only once when seconds are at 10 ... you really need to start at the beginning and develop your code incrementally
@jsotola As you can see through the topic, I didn't know how to print and I found out how to thanks to another user, who understood my issue and was patient enough to help me out with that. Thanks to that, now I know that the servo command is being printing multiple of times in one secoond. You are right when you told that if I had followed what you seuggested earlier, I would have found the issue earlier... But I am a beginner, I had no idea how to do it when you told me... And you didn't tell me how either. That's ok, I also appreciate that you are giving me your support your way here.

last day (15 days later) »