PWM servo control

BBX:
First, thanks for the reply :smiley:

See, I don't know how x(

I feel absolutely ignorant, but once I say:

Servo serv

serv.attach(9);
serv.write(180);




I don't know how to stop the servo. It just keeps spinning.
I don't want to guess where the value of the pot is and try saying serv.write(90), because I don't want the servo to waste energy by spinning slowly to try to satisfy some fraction of a degree difference.

For a continous rotation servo:

serv.write(180); //will turn at max speed in one direction
serv.write(0); // will turn at max speed in opposite direction
serv.write(90); // will stop rotation

Your actually better off using the serv.writeMicroseconds(uS) command as then you can use actual microsecond values rather then degrees, so:

servo.writeMicroseconds(1000); //will turn at max speed in one direction
servo.writeMicroseconds(2000); // will turn at max speed in opposite direction
servo.writeMicroseconds(1500); // will stop rotation, you may have to tweek this value a little due to actual
// servo calibration variation due to the disconnected feedback pot.

Lefty