![]() |
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! :) |
Re: Need a Code for Solenoid to Shift
What language?
|
Re: Need a Code for Solenoid to Shift
English.
|
Re: Need a Code for Solenoid to Shift
Language as in, does your team use C++, Java, LabVIEW?
|
Re: Need a Code for Solenoid to Shift
Quote:
|
Re: Need a Code for Solenoid to Shift
Quote:
http://www.chiefdelphi.com/forums/sh...118#post907118 And it includes a Labview example. |
Re: Need a Code for Solenoid to Shift
Sorry, haha. It's Java.
|
Re: Need a Code for Solenoid to Shift
Thanks for clarifying. I didn't know, haha.
|
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.
|
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!! |
| All times are GMT -5. The time now is 02:42. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi