We need help with our microswitch.
We've tested it with the multimeter (returns 5V when not pressed 0V pressed). When we press it, it won't return 1, the only value it returns is 0.
It's plugged into the Digital I/O port (we've already swapped out three sidecars so we know that that's not the issue). Our code is as follows:
Code:
#include "WPILib.h"
#include <DigitalInput.h>
#include <DigitalOutput.h>
#include <DigitalSource.h>
class RobotDemo : public SimpleRobot
{
DigitalInput micro;
public:
RobotDemo(void):
micro(2,14)
{
}
void Autonomous()
{
}
void OperatorControl()
{
while (IsOperatorControl())
{
DriverStationLCD *groundhogs = DriverStationLCD::GetInstance();
while (micro.Get() == 0)
{
groundhogs -> PrintfLine(DriverStationLCD::kUser_Line2, "I'm not pressed!");
Wait (0.005);
groundhogs -> UpdateLCD();
}
groundhogs -> PrintfLine(DriverStationLCD::kUser_Line2, "I'm pressed!");
Wait (0.005);
groundhogs -> UpdateLCD();
}
}
/**
* Runs during test mode
*/
void Test() {
}
};
START_ROBOT_CLASS(RobotDemo);
We've been ripping out our hair over this for two days already. Any suggestions/answers/holy revelations? Thanks!