View Single Post
  #5   Spotlight this post!  
Unread 18-01-2008, 13:27
Kingofl337's Avatar
Kingofl337 Kingofl337 is offline
You didn't see anything....
AKA: Adam
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 1998
Location: Manchester, NH
Posts: 861
Kingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond repute
Send a message via Yahoo to Kingofl337
Re: Reducing the sentivity of the joystick in easyC Pro

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
      }
}
__________________
FIRST Team 501 PowerKnights - Mentor
FIRST Team 40 Checkmate - Mentor Alum
FIRST Team 146 Blue Lightning - Alumni