I've attempted to hook a vex servo module to my arduino with the code provied in the example labled "knob". The actual electric motor just spins and becomes "detached" from the gear. If I rotate the pot(internal to the servo) to the other extreme it works be it keeps turning and the same thing happens.
I opened the servo and measured the Pot. It measured from 2.1k to 114ohms. I looked up the pot(502T) its max is 5k. Is my potentiometer bad causing my servo to keep running to "find" that position either above 2.1k or below 114 ohms? Also, I checked the pot while in the servo circuit.
I also tried to play with my external 10k pot at different extremes. Should I change anything from the example code program because of the vex brand?
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
}
Vex is just a brand name of robotics kit. I bought it a few years ago from radio shack (only because it was local).