|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Need a Code for Solenoid to Shift
Hi, I'm a new programmer. I've been assigned the task to make a solenoid shift when a button is pushed (such as buttons 4 and 5 on a joystick [tank drive]).
If anyone has a fully functional code that allows a solenoid to shift with a push of a button, please reply with it here. It would be very helpful and I'd really appreciate it. Thank you! ![]() |
|
#2
|
||||
|
||||
|
Re: Need a Code for Solenoid to Shift
What language?
|
|
#3
|
|||
|
|||
|
Re: Need a Code for Solenoid to Shift
English.
|
|
#4
|
||||
|
||||
|
Re: Need a Code for Solenoid to Shift
Language as in, does your team use C++, Java, LabVIEW?
|
|
#5
|
|||
|
|||
|
Re: Need a Code for Solenoid to Shift
Thanks for clarifying. I didn't know, haha.
|
|
#6
|
||||
|
||||
|
Re: Need a Code for Solenoid to Shift
Assuming you have a double-acting solenoid, you want to use the DoubleSolenoid class. DoubleSolenoid.set() is the method that shifts the solenoid.
|
|
#7
|
|||
|
|||
|
Re: Need a Code for Solenoid to Shift
The code below allows a joystick on port 1, to extend/retract a solenoid on port 1 by pushing button 1. It also adds a simple debump statement which makes the solenoid change state only when the button is first press.
<CODE> //Instance Variables public Solenoid shifter; public Joystick joy; //IN CONSTRUCTOR shifter = new Solenoid(1);//1 is the port number joy = new Joystick(1); //IN TELEOP METHOD boolean firstPress = true; boolean inHighGear = false; while(true){ if(joy.getRawButton(1) && firstPress){//first button inHighGear = !inHighGear; firstPress = false; }else if(!joy.getRawButton(1)){ firstPress = true; } shifter.set(inHighGear); } </CODE> Hope this helps!! |
|
#8
|
||||
|
||||
|
Re: Need a Code for Solenoid to Shift
|
|
#9
|
|||
|
|||
|
Re: Need a Code for Solenoid to Shift
Sorry, haha. It's Java.
|
|
#10
|
|||||
|
|||||
|
Re: Need a Code for Solenoid to Shift
What happened to the last person to answer that question that way:
http://www.chiefdelphi.com/forums/sh...118#post907118 And it includes a Labview example. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|