View Single Post
  #3   Spotlight this post!  
Unread 08-02-2008, 04:59
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 689
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: Joystick help (Rookie)

The following code will scale down your joystick sensitivity:

if your original code was

Code:
pwm01 = p1_y;
change it to:

Code:
pwm01 = ( ((signed int)p1_y) - 127 ) / 2 + 127;
Change pwm01 and/or p1_y according to which PWM output and joystick you are using. You can change the scaling factor by changing the 2 (right now it's set to 1/2). For example, to set it at 1/3 power, change the 2 to a three. If you want to use a fraction like 2/3, change / 2 to * 2 / 3. Note: use fractions this way and not decimals, as it will make your code run faster because it only does integer math.

Hope that wasn't too confusing,
--Ryan

Edit: That's for MPLAB. If you're using EasyC, I'm not sure if I can help as much.

Last edited by RyanCahoon : 08-02-2008 at 05:05. Reason: Sudden realization