Thread: Basic Question
View Single Post
  #4   Spotlight this post!  
Unread 19-01-2007, 19:54
itsme itsme is offline
Registered User
FRC #2217 (FOMH)
Team Role: Programmer
 
Join Date: Dec 2006
Rookie Year: 2007
Location: Israel
Posts: 86
itsme is an unknown quantity at this point
Re: Basic Question

In order to set a value to 200 to a motor in port 1 when a button is pressed, You need to do the following: do a while loop that never ends:
Code:
 while(1)
Now, from the RC_Control functions drag and drop Digital OI Input function and in port enter the port of your joystick, in button return the button you want (let's say 1), and in retrieve into a local variable you made before that (let's call it buttonStatus (initialize it to be 0)). Now, do a while(1) loop. In the loop check: while(buttonStatus!=0) then do the following: drag the SetPWM from the output functions. Enter port 1, speed 200. Then, in the same inner loop, enter the Digital OI Input function in order to know if the button was released.
Now it should work
*could be that buttonStatus needs to be equal to 1 at the beginning and the while condition to !=1.

There is another, more better way to do it:
Do a while(1) loop, in it put the OI to PWM function from the RC_Control function blocks, and in the joystick port enter the joystick port, in the axis put the y axis (number 2) and in the PWM# put 1 (the PWM port). Now you can use your motor with the analog joystick (the motor has to be connected to a victor in order to set different speeds).
Hope I helped you

Last edited by itsme : 19-01-2007 at 20:08.