Is there somebody out there who could show me the code required to use channel 5 and/or 6 to control a servo rotation cw or ccw from neutral position?
Our problem is that on power up the servo aligns itself to neutral positon and just using a servo module in EasyC means you have to hold the button to keep it in a certain direction. We just want to use the buttons to control cw and ccw and have it stay there when your finger is off the button. At some point I assume there will need to be code added for error control so that the servo won’t max out and overheat.
Thanks
Try this:
int rx5 = 127;
int servoAngle = 127;
unsigned long incrementTimer = 0;
StartTimer ( 1 ) ;
while ( 1 ) // loop forever
{
incrementTimer = GetTimer ( 1 ) ;
rx5 = GetRxInput ( 1 , 1 ) ; // get data from the controller
if ( rx5 == 0 && incrementTimer > 10 ) // If Channel 5 button = Pressed && It's been 10ms since last increment
{
servoAngle++ ; // add 1 to current value
PresetTimer ( 1 , 0 ) ; // reset the timer back to 0
}
else if ( rx5 == 255 && incrementTimer > 10 ) // If Channel 5 button = Pressed
{
servoAngle-- ; // subtract 1 from current value
PresetTimer ( 1 , 0 ) ; // reset the timer back to 0
}
SetServo ( 1 , servoAngle ) ; // set the servo angle
}
I will give it a try. Thanks.