View Single Post
  #2   Spotlight this post!  
Unread 09-02-2009, 12:08
pheadxdll pheadxdll is offline
Registered User
AKA: Alex
FRC #1225 (Amperage Robotics)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2006
Location: North Carolina
Posts: 168
pheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud of
Re: joystick and relay programming plz help!

You can use the GetX method from the Joystick class to return a float of the joystick from -1.0 to 1.0:

If you lean over half way to the left (on the x axis) it turns the relay reverse. The opposite then for the right direction and then off for in the middle.

Code:
if(thirdStick->GetX() < -0.5) // IF OVER HALF WAY LEANING TO THE LEFT
     agitator->Set(Relay::kReverse);
else if(thirdStick->GetX() > 0.5) // OVER HALF WAY TO THE RIGHT
     agitator->Set(Relay::kForward);
else // NEITHER/IN BETWEEN
     agitator->Set(Relay::kOff);
__________________
Amperage Robotics Team 1225
Site under-going revamp. :/

Last edited by pheadxdll : 09-02-2009 at 12:13.