I'm trying to decrease the maximum range of the joystick on the x-axis using EasyC because the robot turns too fast on the x-axis. I tried using arcade mode at first, but I don't see a way of limiting the joystick range or the PWM output via the Arcade function.
What I tried to do was limit the PWM input. As a test, instead of being 0 (Minimum output), it is now 77, and it is 177 as a maximum. I used the following code and it doesn't seem to work. Does anyone know how I can do this?
Code:
unsigned char Port1XAxis = 127;
while ( 1 )
{
OIToPWM ( Port1XAxis , 1 , 1 , 0 ) ;
if ( Port1XAxis <= 77 )
{
Port1XAxis = 77 ;
//SetPWM ( 2 , 177 ) ;
//SetPWM ( 1 , 177 ) ;
}
else if ( Port1XAxis >= 177 )
{
Port1XAxis = 177 ;
//SetPWM ( 2 , 77 ) ;
//SetPWM ( 1 , 77 ) ;
}
Arcade2 ( 1 , 2 , 0 , 0 , 2 , 1 , 1 , 1 ) ;
I know this code has some errors, but can someone help me figure out how to do something like this?
Thanks a lot.