Servo motor


I am currently working on an automatic dog feeder, and I am using a servo motor to do so (to dispense the food). I got the servo motor to move, but is it possible to set the angle of the servo, and make it run a certain time, then stop? Thanks.

When you say run a certain time, do you mean run for a certain number of seconds? It would make more sense to have it move a number of degrees, from a start point to an end point. Your mechanical design would let you know what both of those are, and you would simply code the servo.write(pos) commands to move from one to the other.

Servos typically move at a speed dictated by their design (the datasheets usually give the number of seconds to move 60 degrees) and the load you impose on it. The actual time taken to move is probably not important in your case: you're more concerned with the "flap" or whatever it is being opened properly, I'd guess.

Do you mean a hobby servo of the type used to move the controls in flying model aircraft? That is the sort of thing @JimboZA is talking about.

There are also completely different types of expensive servo motors that are used in commercial CNC machines.

The reason I ask is because the hobby ones are usually just referred to as servos (not servo motors) and they are usually moved to different angles rather than for a given time. Of course they can be made to stay at a particular angle for a given time and then move to another position.

Assuming you are using a hobby servo ...

You can use the timing technique in the Blink Without Delay example sketch to manage the timing.

And f you look at the servo Sweep example you will see how you can move them a little bit at a time to slow them down.


Come to think of it, timing isn't really important. The only thing I need is for the servo to move to a certain angle, then move back. Thanks guys!