Piston code I made does not work


#1

So I made this simple code I made using WPI’s screensteps on DoubleSolenoid and I put it in Robot.java. However, when I enabled the robot, the compressor and the PCM already gathering air and the piston comes out immediately before I even pressed the button.

Robot.java

I’m using Command based.


#2

Instead of using koff, try using kreverse… if you are trying to test it moving back and forth


#3

This is expected - simply declaring the solenoid in code will start the compressor automatically.


#4

Okay, I’ll do but when I enable Teleop, the piston already comes out before I even pressed the button.


#5

Do kReverse instead of kOff in your else statement.


#6

You can solve this multiple ways:

  1. Swap the plumbing on the Piston. It sounds like your high/low pipes are reversed.
  2. Use kReverse in your if() statement and kForward in your else statement. Not preferred, but it should work.

#7

you can also initialize to be in desired position by declaring it in the robotinit. then you can make sure that it always starts on the same position