Turning servo with ds3231

In this part of the code, I want the servo to rotate four times at exactly 3:00 pm.
I have tried so many different code constructs but still the servo doesn't move at the appointed time.
I am using RTClib.
Last version of the code:

void feed(){
  bool counter = 0;
  DateTime now = rtc.now();
  if(now.hour() == 15 && now.minute() == 0 && now.second() == 0){
    counter = 1;
  }
switch(counter){
  case 1:
  Servo1.write(180);
  Servo1.write(0);
  Servo1.write(180);
  Servo1.write(0);
  counter = 0;
  break;
  case 0:
  Servo1.write(0);
  break;
}
  }

Please post your full sketch so that variable declarations etc can be seen in context

  Servo1.write(180);
  Servo1.write(0);
  Servo1.write(180);
  Servo1.write(0);

The code does not wait until the servo reaches its commanded position before moving on to the next command. Can you see the problem ?

Thanks a lot. I've been stuck with such a simple problem for a long time.

I am glad that the penny has dropped

Do you know how to fix the problem ?

Is the sketch required to do anything else whilst the servos are moving back and forth ?

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