View Single Post
  #6   Spotlight this post!  
Unread 11-02-2006, 15:54
Calvin Calvin is offline
Registered User
no team
 
Join Date: Feb 2005
Location: Portland OR
Posts: 105
Calvin has a spectacular aura aboutCalvin has a spectacular aura about
Re: issues limiting a joystick input

so when:

input -> output
x -> y
0 -> 100
255 -> 155

Slope: y2-y1/x2-x1
Slope: 155-100/255-0
Slope: (11/51)

y = mx + b
y = 11/51x + b
100 = 11/51(0) + b
b = 100

so: y = (11/51)x + 100
so: pwm16 = ((11/51)*p3_x) + 100;

PHP Code:
if (p3_sw_top == 1)
{
     
pwm16 = ((11/51)*p3_x) + 100;
}
else
{
      
pwm16 p3_x;


Last edited by Calvin : 11-02-2006 at 16:01.