View Single Post
  #2   Spotlight this post!  
Unread 21-03-2010, 22:33
TubaMorg TubaMorg is offline
Programmermechanicalelect ricalcoach
AKA: Dan
FRC #1480 (Robatos Locos)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Houston
Posts: 450
TubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond repute
Re: Servo control with a joystick

Use the Servo class.
It has two methods you can use:

set(double value) where value = 0.0 to 1.0 for full range of motion

setAngle(double degrees) where degrees = position of the servo...values in excess of allowable range of motion simply saturate to the servo limit. The API assumes that the kit servos are linear.

So to answer your question. Since the joys run from -1 to 1, you can simply use a multiple for the set method:

Code:
Servo servo = new Servo(1);//Servo in PWM port 1
double servoIn = (joy.getX() +1)*0.5;

// Command to servo
servo.set(servoIn);


That should do it.
__________________
I don't need a signature.
Reply With Quote