Quote:
Originally Posted by Brian Ho
You need to use Which gets you the boolean value of the limit switch which may be true or false depending if you wired it as normally opened or normally closed.
|
To fit this into my earlier recommendation about collecting the inputs and outputs at the edges of the code, be sure your limit switch has a meaningful name and that "true" and "false" make sense. then you only have to do inversion once when you read the input, and not have to think about it when you use it later.
Code:
boolean intakeHitLimitInNegativeDirection = !limitswitch.get();
...rest of code...
and be sure your electrical team keeps consistent wiring on motor connections, such that sending a positive command always moves your motor in the same direction from system to system. Even better, label the mechanism with arrows specifying the plus direction until you are fully confident in all your code.
For future code, consider looking at the command template. It feels more complicated than iterative, but certain concepts in command are far more powerful than iterative, and Robot Builder is a big benefit as well.