|
Re: Joystick Programming
Hi there.
ROBOTC makes using the joystick very easy. If you wanted to use the joysticks to drive your robot you could the following code:
while(true){
motor[port1] = frcRF[p1_y]; //maps pwm port 1 to the Y axis of Joy1
motor[port2] = frcRF[p2_y]; //maps pwm port 2 to the Y axis of Joy2
{
You can in exchange slow down the motors and still retain the joystick "movement" by dividing the values you're getting from the joystick... like in this example:
while(true){
motor[port1] = (frcRF[p1_y] / 2); //maps pwm port 1 to half the value of the Y axis of Joy1
motor[port2] = (frcRF[p2_y] / 2); //maps pwm port 2 to half the value of the Y axis of Joy2
{
__________________
2003 - Rookie All-Stars Awards - #1185 (Pittsburgh)
2004-2008 FIRST Volunteer - Ref/Head Ref (Pittsburgh)
2002-2007 FIRST Lego League Volunteer - Head Ref (Pittsburgh)
|