View Single Post
  #11   Spotlight this post!  
Unread 30-01-2008, 20:28
timville's Avatar
timville timville is offline
Registered User
AKA: Timothy Friez
FRC #1185 (X-Bots)
Team Role: Alumni
 
Join Date: Mar 2007
Rookie Year: 2003
Location: Pittsburgh
Posts: 18
timville is an unknown quantity at this point
Send a message via AIM to timville
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)