STEM is the new cool, STEM is the new fun, but nobody said STEM is the new easy. - Taylor [more]
 Chief Delphi joystick and relay programming plz help!
 Team 51 CD-Events CD-Media CD-Swap CD-Spy FRC-Spy Unsung FIRST Heroes WFA
The Chief Delphi Forums are sponsored by Innovation First International, Inc.

#1
02-09-2009, 09:48 AM
 programmr Registered User AKA: Face FRC #0522 Team Role: Programmer Join Date: Jan 2008 Rookie Year: 2006 Location: Staten Island, NY Posts: 83
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

__________________
"I would love to change the world but no one will give me the source code"
#2
02-09-2009, 11:08 AM
 pheadxdll Registered User AKA: Alex FRC #1225 (Amperage Robotics) Team Role: Programmer Join Date: Jan 2007 Rookie Year: 2006 Location: North Carolina Posts: 168
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 : 02-09-2009 at 11:13 AM.
#3
02-09-2009, 12:22 PM
 programmr Registered User AKA: Face FRC #0522 Team Role: Programmer Join Date: Jan 2008 Rookie Year: 2006 Location: Staten Island, NY Posts: 83
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"

 Thread Tools Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 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 User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements     User Announcements FIRST     General Forum         FIRST E-Mail Blast Archive     Rumor Mill     Career     Robot Showcase     Moderated Discussion Technical     Technical Discussion     Robotics Education and Curriculum     Motors     Electrical         CAN     Programming         NI LabVIEW         WindRiver C++         Java         MATLAB & Simulink         Python     intelitek easyC/REC information         easyC v2 for Vex         easyC for FRC         REC/Learnmate         WPILib         easyC PRO     Control System         IFI Control System         FRC Control System         Sensors         USB Chicklet     Pneumatics     Kit & Additional Hardware     CAD         Inventor         SolidWorks         Pro ENGINEER / Creo     IT / Communications         3D Animation and Competition         Website Design/Showcase         Videography and Photography         Computer Graphics     National Instruments LabVIEW and Data Acquisition         LabView and Data Acquisition Competition     Awards         Chairman's Award     Rules/Strategy         Scouting         You Make The Call     Team Organization         Fundraising         Starting New Teams         Finding A Team         College Teams     Championship Event     Regional Competitions     FIRST in Michigan     Mid-Atlantic Robotics     Off-Season Events         Chief Delphi Invitational     Thanks and/or Congrats     FRC Game Design     OCCRA         OCCRA Q&A         OCCRA Programming Other     Unsung FIRST Heroes     Chit-Chat         Games/Trivia             Fantasy FIRST     Car Nack's Corner     College & University Education     Dean Kamen's Inventions     FIRST-related Organizations         Western Region Robotics Forum         Robot Chicks Union (RCU)         Southern California Regional Robotics Forum         Hearing-Impared Network         FIRST Interactive Rural SupporT         freelanceFIRST         FIRST Scouting Network         openFIRST         The Grand FIRST Team         FloridaFIRST         Inspiration Foundation Inc.         South Dakota FIRST         FIRST International Partners         FIRSTwiki         Ultimate Robot Challenge         East Coast Drivers Union         Team San Diego         CollegiateFIRST         Dream FIRST         FIRST Brasil         The Blue Alliance             Video Archives     FIRST Historians     FIRST-A-Holic's Anonymous Mailbox     FIRST In the News...     FIRST Lego League         Lego Mindstorm Discussion     FIRST Tech Challenge         FTC E-Mail Blast Archive     VEX         VEX Robotics Competition     Televised Robotics     Math and Science         NASA Discussion ChiefDelphi.com Website     CD Forum Support         Bulletins and Newsletters     Extra Discussion Old Forum Archives     1999     2000     2001

 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 01-28-2009 09:34 PM Joystick Button Programming in Labview Help Needed domoarigato NI LabVIEW 11 01-28-2009 09:55 AM Programming Joystick Buttons to toggle a motor on and off programmr WindRiver C++ 6 01-25-2009 04:47 PM Programming Help- 2 Motor 2 joystick Drive System OMAR_567 Programming 2 02-02-2008 01:08 PM i need specs for motors and pumps in the kit from last years competition plz help SCYTE16 Motors 3 11-18-2004 09:54 PM

All times are GMT -5. The time now is 03:52 PM.

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

 -- English (12 hour) -- English (24 hour) Contact Us - Chief Delphi - Rules - Team Site - Archive - Top