Setting up & Sensoring Cherry Switches

Alright again, don’t know where to put this at but, im trying to setup 2 cherry switches, and for now i want them to be setup into the roboRIO, and have them get sensor as like once its pushed it shows its on, and pushed again its off. How do i go by doing this?

DIO%20Code

See the attached picture. In the Begin.vi, you need to open two digital input RefNums and assign them names. You also need to assign the DIO port, which is the DIO port on the RoboRIO that the switch is connected to. Then, in the Teleop.vi (or Autonomous, or Periodic Tasks), use the RefNum get and then get the value of the switch. The boolean value is TRUE when the signal pin is high (5V) and FALSE when the pin is low (0V).

Thanks, and now how do i go by having it shut the motor off when its pressed, and turn on when unpressed?

Motor%20Shutoff%20Code

Here’s an example. This is for just a single PWM SPARK motor controller, but the logic stands for setting the output of any motor. The triangle block is a Select function, which is under the Programming >> Comparison palette.
The value of the boolean detemines which of the two values is output. The top value if it’s TRUE, and the bottom value if FALSE. This way, the output is zero when the button is pressed. When it isn’t pressed, the output is the motorOutput variable (which could be from a joystick, or a constant value).

When you wire the switch you want to use the Sig wire and the GND wire from the DIO channel.

There is actually very little difference between the two but I prefer the Switch VIs rather than the DIO VIs. While what Pi_Fighter is true this actually means when the circuit is open, the DIO Get VI returns True and when the circuit is closed, the DIO Get VI returns False. With the way my brain works, this seems backwards. The Switch VIs use the DIO VIs internally but by default invert the output of the Get VI. I you then decide you want it to be the other way, there is a “Normally Closed” terminal on the Open VI that works much like the Invert inputs on the Motor open VIs and inverts the value back the other way.
If the last paragraph confuses you, just ignore it.

Yep there are examples installed with LabVIEW for “Limit Switch” and “Simple Digital Input”. I’m sure you can find them.