Submitted by Webbot on January 1, 2009 - 11:31pm.
This class is used to drive a modified servo via a general output pin.
So all of the methods of Motor are available.
To create a new servo motor pin you must first define an output pin eg.
OUT g_servoSonarOut('B', 7); // define B7 as an output pin
SERVO g_servoSonar(&g_servoSonarOut, false, 1500, 500); // create a servo on B7, non-inverted, center=1.5ms, 0.5ms either side
If your motor is running in the wrong direction then change
the 'false' parameter to 'true' - you don't need to change anything
else.
The last two parameters specify the pulse width to center the
servo (ie 1.5ms) and how much the pulse width varies on either side of
that value. NB The last 3 parameters are optional and if they are
missing then they will be assumed to be false,1500,500 respectively.
Note that a servo should only send out an action every 20ms. This class remembers when the speed was last set for each servo and so if you try to change the speed quicker than this then the class will make sure that all is well. So your main loop doesn't need any delay for the servos.