Log in

View Full Version : Switch Program


DavisC
29-02-2012, 13:08
Using the Honeywell Switch on the robot. What declaration do I use? And how do I get the state it is in? Do I use the DigitalIOButton to declare it and just use the Get() which returns a bool value?

Thanks in advance!
Davis

mikets
29-02-2012, 13:22
The DigitalIOButton class is for a button on the DriverStation (e.g. connected to the Cypress module). Are you using that? Or is your switch connected to the robot? I am assuming it's on the robot. If so, are you connected it through some digital input channel? The way to access a switch connected to a digital input channel is something like this (assuming digital input channel 1):

DigitalInput limitSwitch(1);
...
...
limitSwitch.Get();

DavisC
29-02-2012, 13:23
Yes the switch is on the robot connected to DIO port 1 on the DSC.

synthmusic
13-03-2012, 00:42
Yes the switch is on the robot connected to DIO port 1 on the DSC.
Not sure if this is what you are looking for, but as an example we have a switch used as a travel limit to stop a motor. It's used as follows:



DigitalInput *bBallElevatorTopLimit;
...
bBallElevatorTopLimit = new DigitalInput(2,2);
...
// if top limit clicked
if (!bBallElevatorTopLimit->Get())
...

the switch reports 1 when it is open and 0 when closed because we wired the switch signal to ground on the DSC.

Hopefully that helps!