This is how this would look in easyC
Code:
void OperatorControl ( void )
{
int joy_y_port1;
int joy_y_port2;
unsigned char left_output;
unsigned char right_output;
while ( 1 )
{
joy_y_port1 = GetOIAInput ( 1 , 2 ) ; // Get Joystick Data
joy_y_port2 = GetOIAInput ( 2 , 2 ) ; // Get Joystick Data
/* Remove 127 Setting the joystick scale from 0-255 to -127 0 127.
Then Divide the output in half and then add 127 back to return the
scale to 0-255.*/
left_output = ((joy_y_port1 - 127 ) / 2) +127 ; //See Above
right_output = ((joy_y_port2 - 127 ) / 2) +127 ; // See Above
SetPWM ( 1 , left_output ) ; //Send left output to PWM1
SetPWM ( 2 , right_output ) ; //Send right output to PWM 2
}
}