![]() |
Help Please!(Rookie Team)
I am looking for basic java programming code to turn on and off compressor. I have power from compressor connected to a spike relay per rules. I understand how to talk to a Jaguar, but believe that I plug PWM from spike into digital sidecar relay slots. IS this correct and if so please send a simple program that will use joystick(2) buttons 10 and 11 to turn power on and off to compressor using spike.
Thanks a million. NEAL and or anyone else that can help |
Re: Help Please!(Rookie Team)
I don't really know the electrical side of things here, but I do know that there's a pretty simple method for using Spike relays: the Relay class.
Basically, you initialize one with the required port and the direction: Code:
Relay relay = new Relay(PORT,direction); // direction can be Relay.Direction.kFoward,Relay.Direction.kReverse, or Relay.Direction.kBothCode:
relay.set(Relay.Value.kOff); // 0v-0v, any direction |
Re: Help Please!(Rookie Team)
Quote:
relay.set(Relay.Value.kForward or kReverse) Should be relay.setDirection(Relay.Direction.kForward or kReverse, or kBoth); Hope this helps! Happy Competitions! |
Re: Help Please!(Rookie Team)
Quote:
I'm getting all my info about the relay from the source (from sunspotfrcsdk/lib/WPILibJ/src/edu/wpi/first/wpilibj/Relay.java in this case), in case you want to check my info ;) |
Re: Help Please!(Rookie Team)
Quote:
|
Re: Help Please!(Rookie Team)
There is a compressor method that handles the relay for you.
Code:
Compressor(int pressureSwitchChannel, int compressorRelayChannel)Code:
Compressor compressor = new Compressor(1,1); |
Re: Help Please!(Rookie Team)
Awesome, but where does the code go ?
|
Re: Help Please!(Rookie Team)
Quote:
|
Re: Help Please!(Rookie Team)
if (!airCompressor.getPressureSwitchValue())//check if the compressor is working
{ airCompressor.setRelayValue(Relay.Value.kOn); } else { airCompressor.setRelayValue(Relay.Value.kOff); } ^^^ You also need this in the continuous function |
Re: Help Please!(Rookie Team)
Quote:
|
| All times are GMT -5. The time now is 09:54. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi