Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Need a Code for Solenoid to Shift (http://www.chiefdelphi.com/forums/showthread.php?t=130918)

Emiko 26-10-2014 17:38

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! :)

cgmv123 26-10-2014 17:55

Re: Need a Code for Solenoid to Shift
 
What language?

Emiko 26-10-2014 17:56

Re: Need a Code for Solenoid to Shift
 
English.

cjl2625 26-10-2014 18:00

Re: Need a Code for Solenoid to Shift
 
Language as in, does your team use C++, Java, LabVIEW?

cgmv123 26-10-2014 18:01

Re: Need a Code for Solenoid to Shift
 
Quote:

Originally Posted by Emiko (Post 1405808)
English.

Sorry, what programming language? Java, C++, or LabView.

EricH 26-10-2014 18:04

Re: Need a Code for Solenoid to Shift
 
Quote:

Originally Posted by Emiko (Post 1405808)
English.

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.

Emiko 29-10-2014 00:12

Re: Need a Code for Solenoid to Shift
 
Sorry, haha. It's Java.

Emiko 29-10-2014 00:13

Re: Need a Code for Solenoid to Shift
 
Thanks for clarifying. I didn't know, haha.

cgmv123 29-10-2014 10:14

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.

Secretspy97 29-10-2014 14:16

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