im trying to create a code that needs to stop a motor from moving and move it backwards for a short time, when a limit switch is pressed, first we are trying to start a motor using a limit switch, but we cant, any help is appreciated.
Code:
#include "WPILib.h"
class Robot: public SampleRobot
{
Talon Motor;
DigitalInput limitSwitch;
public:
Robot():
limitSwitch(1),
Motor(6)
{
}
void OperatorControl()
{
while (IsOperatorControl() && IsEnabled())
{
if(limitSwitch.Get()>0)
{
Set.Motor(1.5,0);
}
}
}
};
START_ROBOT_CLASS(Robot);