Detecting the status of a solenoid.

Is there a way of detecting the status of a solenoid?

solenoid is kFoward // <--- what goes here??
   light turns on
   light turns off

You could have a variable that tracks the solenoid state. Initialize the solenoid and that variable to the same state at the beginning; change the variable every time you send a command to the solenoid.

It helps if you use a function to combine the two actions (set the solenoid value and the tracking variable value) into a single action. That way, you are less likely to forget to change the tracking variable and end up with an disagreement between code and reality.

Check the API docs.

If it’s like java, solenoid.get() (or solenoid->get()) might be the method you’re looking for. As I recall, it “remembers” the last state given to the solenoid, it does not “detect” it.

So this probably.

if ( DoubleSoldnoid ->Get() == kfowards )
  light on
  light off