Problems with running Solenoids through Commands toggled by Buttons

I’ve made a simple command to enable a solenoid and tried to use the whenPressed() and toggleWhenPressed() methods to call the command from teleop. It works fine when using motors however solenoids don’t work properly even though they work when calling the normal method from a subsystem.
Example Code:
OI.intakeButton.whenPressed(new IntakeCommand(true));
The weird thing is that a red indicator will show up on the robot indicating that the solenoids are enabled, however there is no action even though they work properly without using commands. I’d be grateful for any help from anyone who has faced any similar issues or has some more knowledge/experience about how these functions work.

If the red indicator on the PCM is turning on and off, then it would seem that your software is working fine and it could be a wiring problem or issue with the solenoid.

I know for sure it’s not a wiring/mechanical issue because the solenoid will work fine with previous iterations of code that don’t use commands and simply rely on methods from subsystem. I’m speculating that there might be some kind of incompatibility with the whenPressed() function and solenoids/boolean data types although the WPI documentation doesn’t mention anything like that.

Hm, if the light below the port on the PCM comes on, that indicates the output is “on” (and vice versa) indicating the PCM is triggering the solenoid.
Where is the red indicator you mentioned in your original post?
Could you post the execute section of your IntakeCommand command?

I’d also check that you have the latest images and firmware installed.

When you press the button it passes in a new instance of the command you created, and if you have local variables in that command that holds the previous state, it will get reset every time. You can either schedule a command that runs for the entire teleop, or run the logic inside the subsystem

As a non-software fix, make sure that your PCM is set to the correct voltage setup for your solenoids. It has a jumper to switch between 12 and 24V.

Is this a pneumatic solenoid valve? Note that these are air piloted, so you must have air pressure (typically 30 or 40 psi) for them to actually change state.

I got the problem fixed after messing around with the code. Apparently there were conflicting uses of the booleans that control the solenoids. Thanks for the help though.