I'm planning to control several servos with my arduino and was wondering what the difference was between the various methods I found on the internet.
When looking on the internet for code to control a servo, I came upon code that controls a servo by repeatedly sending a pulse of a specific amount of uS to a digital pin. These pulses have to be continuesly 'fired' for the servo to operate.
The other method I found was using the servo library that basically does the same, only in the background and the coding is more easy for all the functionality is in the library.
So choosing from the upper two methods, using the library is the more easy one.
But isn't it possible to just set a digital pin to PWM output and send pulses that way?
Why don't I see some code with that method? Is this not possible?
But isn't it possible to just set a digital pin to PWM output and send pulses that way?
It is...but you really don't want to.
Your servo would probably not run very efficiently, and could use more power.
R/C servos use Pulse Position Modulation (PPM) not Pulse Width Modulation (PWM) to control them.
On the face of it they're similar, in that PPM looks like a very low (<10%) duty cycle PWM signal.
However, you'd probably find that using even correctly timed PWM would result in fairly coarse control of the servo.
You're best using the servo libraries - they're very simple to use.
Well, that's great, thanks.
That was just the information I was looking for.
(Great forum this is...answer within 30 minutes...)
So, I will use the library then.
Another question:
I have two hitec sevos (for a pan/tilt mechanism).
Does anyone think I can power these from the 5v of the Arduino, connected via USB to my pc (so without an extra powersource)?
Always use an external supply to power servos.
OK, I will.
Thanks.