Go to Post If you need persuasion woven tight with logic, leave it to a software architect. - Richard Wallace [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 09-02-2009, 10:48
programmr's Avatar
programmr programmr is offline
Registered User
AKA: Face
FRC #0522
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Staten Island, NY
Posts: 83
programmr is a jewel in the roughprogrammr is a jewel in the roughprogrammr is a jewel in the rough
Send a message via AIM to programmr
Question joystick and relay programming plz help!

i have

Joystick* thirdStick; //Joystick USB3
Relay* agitator; //Relay 1
Relay* agitator2; //Relay 1

thirdStick= new Joystick(3);
agitator = new Relay(1, agitator->kBothDirections);
agitator2 = new Relay(1, agitator2->kBothDirections);

if (thirdStick->GetRawButton(1)) {
agitator->Set(agitator2->kReverse);
}
else {
agitator->Set(agitator2->kOff);
}

i want to know how can i make the relay go forward and then go reverse based on either the x or y axis of the joystick: example:

x axis : left makes relay1 go rev, right makes relay1 go fwd

Please help! thank you!
__________________
"I would love to change the world but no one will give me the source code"
  #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.
  #3   Spotlight this post!  
Unread 09-02-2009, 13:22
programmr's Avatar
programmr programmr is offline
Registered User
AKA: Face
FRC #0522
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Staten Island, NY
Posts: 83
programmr is a jewel in the roughprogrammr is a jewel in the roughprogrammr is a jewel in the rough
Send a message via AIM to programmr
Re: joystick and relay programming plz help!

thank you very much!
__________________
"I would love to change the world but no one will give me the source code"
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I program a relay to turn on and off by pressing a button on the joystick? eweathers NI LabVIEW 4 28-01-2009 22:34
Joystick Button Programming in Labview Help Needed domoarigato NI LabVIEW 11 28-01-2009 10:55
Programming Joystick Buttons to toggle a motor on and off programmr C/C++ 6 25-01-2009 17:47
Programming Help- 2 Motor 2 joystick Drive System OMAR_567 Programming 2 02-02-2008 14:08
i need specs for motors and pumps in the kit from last years competition plz help SCYTE16 Motors 3 18-11-2004 22:54


All times are GMT -5. The time now is 02:34.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi