fisico30 said:
thanks vk6kro,
I guess I also need a PWM chip, a pulse width modulator chip, since the servo motor is controlled by a pulsed signal.
In essence, two sensors, physically connected to servo and electrically to Arduino, a PWM chip that allows communication between the Arduino and the servo after Arduino receives the signals from the sensors...
Does that sound like a good plan? do I really need the PWM chip?
thanks
fisico30
A servo has to get a very specific type of pulse to work.
Servos require a pulse of 0.75 to 2.25ms every 20ms, and this pulse must be constantly repeated every 20ms. The range of pulses from 0.75 to 2.25ms control the position of the servo.
So, I don't think you can do this with a PWM chip.
The Arduino apparently does have SERVO commands:
Code
// Controlling a servo position using a potentiometer (variable resistor)
// by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}
I have no experience with Arduino, though, so you need to check how to do this.