Driving a PWM servo from analog signal - how to?

Hi ya,

Anyone able to give me guidance for programming a UNO –

I wish to take a 0-6V DC signal to drive a standard 6-8 Volt servo via a UNO based upon this signal from another device that puts out a clean linier signal based upon position.

My requirement is for the Arduino - 0V input servo is closed, 3V input – servo ½ way. 6 volts servo fully open.

thus converted to run servo - As a servo has PMW, I believe common 1ms is closed, 1.5ms is mid, 2ms is fully open.

Anyone able to assist with programme for the above from 0-6V to servo drive? Cheers Lyndon

The arduino won't tolerate the 6V input. You need to drop it to 5V max.
You can use a voltage divider or a level shifter.

for your code use the servo library. Try something like this

void loop()  {
  int potValue;  // variable to read potentiometer
  int servoPos;  // variable to convert voltage on pot to servo position
  potValue=analogRead(POTPIN);                // Read voltage on potentiometer
  servoPos = map(potValue, 0, 1023, 0, 179);  // scale it to use it with the servo (value between 0 and 180) 
  myServo1.write(servoPos);                    // tell servo to go to position
}