Control speed of a Parallax Feedback 360 Motor

I pointed out the same problem with your normal servo example several posts ago

1 Like

I guess I thought that by using the for loop, this was being accomplished. I guess not. Hmmm

{
  for (Angle = 220; Angle <= 320; Angle += 25)
  {
    Servo1.rotate(Angle, 5);
    delay(50);
  }
}

Would putting the delay inside the for loop like this work?

As you have now discovered, the for loop makes the servo move in steps but not slow ones.

Without a delay() in it the for loop will execute in a few microseconds and it is easy to underestimate just how quickly the microprocessor is running

Have you got the servo moving slowly now ?

1 Like

I understand now!

So the for loop process basically starts at the beginning of the for loop, reads through and executes all of it's commands, and then proceeds to the rest of the sketch outside of the for loop? (And then it loops everything again)

Also yes, the servo is moving slower now :slight_smile:

Also, anyone in the future, below is the link to the "FeedbackServo.h" library that I'm using.
https://github.com/HyodaKazuaki/Parallax-FeedBack-360-Servo-Control-Library-4-Arduino

Yes, the for loop executes the code inside its code block once for every step of the for loop before moving on.

If you wanted to do something else in between each servo moves then other techniques such as letting the loop() function doing the looping can be employed

Thank you for helping me expand my Arduino knowledge @UKHeliBob

Glad to have been of help

Good luck with your projects

1 Like

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