Quote:
|
Originally Posted by Joshua May
If I understand you correctly, then this should work. I can't remember the exact two-joystick code, but this concept should be valid.
Code:
if (p1_sw_top)
{
pwm01 = p1_y + 4;
pwm02 = p2_y + 4;
}
if (pwm01 > 138)
pwm01 = 138;
if (pwm02 > 138)
pwm02 = 138;
|
be careful. This won't work exactly as expected. The code above will increment the PWM value EVERY PROGRAM LOOP THAT THE BUTTON IS PRESSED FOR. While you may not press the button for very long, ALOT of program loops occur in this time and your pwm value will go haywire. To prevent this, you need to only increment once when the button is first pressed. An example of how to check if a button was jsut pressed goes somethign like the following:
Code:
int previous_Button_State = 0;
//check to see if the button was just pressed.
if (p1_sw_top & !previous_Button_State)
{
//do stuff here
}
previous_Button_State = p1_sw_top;
Quote:
|
thanks for the help. by the way, I meant 238, not 138. (just stating that cause I feel dumb ) no matter, thanks for the help
|
I was a bit confused as to why you are limiting it that low.
