View Single Post
  #7   Spotlight this post!  
Unread 01-10-2003, 09:35
Neal Turett Neal Turett is offline
Registered User
#0201
 
Join Date: Nov 2002
Location: Rochester Hills
Posts: 34
Neal Turett is on a distinguished road
I'm interperting your request as if you have a joystick, and you want to be able to press a button on it to slow down the robot, in order to make it more controllable.

If this is what you're looking for insert this write after the code block where you tie the p1_y and p1_x (or whatever vars you use) to the pwms:

if (p1_top = 1) then
if pwm1 > 127 then pwm1 = (pwm1-127) / 2 + 127
if pwm1 < 127 then pwm1 = (127 - (127-pwm1) / 2)
endif

Do the same for pwm2. This will reduce the speed of the robot by a factor of 2 when p1_top is pressed.