PDA

View Full Version : Reading Joystick Values Help


FearlessLeader
01-17-2009, 06:52 PM
I need to get the value off the X axis on Joystick(1) the value being 0-256
I need to put the value into a float(JoyStick1Value)

How do I do this code please if you can

Thanks

wt200999
01-17-2009, 07:12 PM
Look in BaeUtilities.h the NormalizeToRange() function

FearlessLeader
01-17-2009, 09:33 PM
#include "WPILib.h"
#include <Joystick.h>

class RobotDemo : public SimpleRobot
{
RobotDrive MyRobot;
Joystick RightStick;
Joystick LeftStick;

public:
RobotDemo(void):
MyRobot(1, 2),
RightStick(1),
LeftStick(2)

{
GetWatchdog().SetExpiration(100);
}

void Autonomous(void)
{

}

void OperatorControl(void)
{
GetWatchdog().SetEnabled(true);
while (IsOperatorControl())

{
RightStick.GetX(); //this is what i need help with
}
}
};

START_ROBOT_CLASS(RobotDemo);


I know i use this but RightStick.GetX(); where do i put the float to get the value

wt200999
01-17-2009, 11:08 PM
What are you trying to do with it?

Alexa Stott
01-17-2009, 11:13 PM
Are you talking about doing smething like:
float variablename = stick.GetX();?

I don't really undestand what you are specifically trying to do.

FearlessLeader
01-17-2009, 11:33 PM
I am sorry i figured it out
(float) = RightStick.GetX();