Servo and Analog Question

Is it possible to use analogWrite() to control a servo? Can you use an analog pin instead of a digital PWM pin to control the position of a servo and if so how? I have read the PWM tutorial but am still a confused.

You can, but you shouldn't.
PWM from an analogWrite runs at just short of 500Hz, but the servo expects 50Hz.
Even if you do get it down to 50Hz, eight bit resolution isn't really good enough to give fine enough control.

Will it damage the servo or Arduino? Do you think it would be fine to run continuos servos off of them if I did not care about the speed. Really all I want them to do is be able to run forward and backward.

What you need to control a servo are pulses 1000-2000 usec long which repeat every 20-msec,
and ideally with 1-usec resolution. IE, 1000 usec, 1001 usec, etc. As AWOL indicated, that's
difficult to get using analog.write(). You notice it's only a 5-10% duty-cycle on a PWM signal,
assuming you can get one to go as slow as 50-hz.

BTW, 1000-2000 usec moves the servo +/-45 degrees from center. And in actuality, most servos
can be driven close to +/-90 deg off center with a wider pulsewidth range, approx 750-2250 usec,
but this varies with the specific servo.

Why not use the Servo library? What you want to do (make a servo move) is exactly what it was designed for.

The servo will probably consume more current at 500Hz than it would at 50Hz, and it could overheat.
Why do you want to do this?
Why not just use the Servo library?

It was often said by some members here that PWM will damage a servo because it needs PPM, pulse position modulation.

In multi-channel R/C, the multiplexed signal carrying all channels between transmitter and receiver is PPM, but by the time it is demultiplexed and reaches the servo or ESC, it really is PWM, but very low duty cycle.
However, the default PWM frequency of the Arduino is far too high for common R/C equipment.

If I use the servo library and have myservo.attach(9) that is saying it is on digital pin 9. How could I change that to analog pin A1?

Will it damage the servo or Arduino? Do you think it would be fine to run continuos servos off of them if I did not care about the speed. Really all I want them to do is be able to run forward and backward.

With continous rotation servos, the servo probably won't be damaged, it just won't operate as you expect. With a regular servo bad control signals can make the servo rotate until it is against the hard stop, where damage then can occurr. Give it a try and see how it works.

The servo will probably consume more current at 500Hz than it would at 50Hz, and it could overheat.

The internal control loops in standard analog servos will not operate at 500Hz. They will operate to
about 100Hz [10-msec update], but any faster than that and the servos goes bonkers under loaded
conditions because the control loops crash. Digital servos can accept faster control updates, but
I'm not up on the details.

Hi,
The Servo library is very good and allows you to control a large number of servos on more or less any pin.

Here is some background -

There are some aliases in Arduino which allow you to refer to the analog pins in digital functions, I haven't tried this myself, but the following may work for you

myServo.attach(A1); // A1 is the alias for analog pin 1, use An for whichever analog pin you want where n = 0 to 5

Duane B

rcarduino.blogspot.com