Quote:
Originally Posted by charlier999
all tho i did the exact same thing except change the name of the wasAPressed to shifter_varable. It still does the exact same thing as before, going hyper-speed switching back and forth.
|
Ok let me make it a bit more clear:
Code:
// File: Robot.cpp
class Robot: public IterativeRobot {
public:
bool wasAPressed = false; // MEMBER VARIABLE. not local variable
// robotInit, teleopInit, autonomousInit, autonomousPeriodic, etc
void teleopPeriodic() {
if (driver->GetRawButton(2)) {
if (!wasAPressed) {
wasAPressed = true;
shifter->Set(shifter->Get() == DoubleSolenoid::Value::kReverse ? DoubleSolenoid::Value::kForward : DoubleSolenoid::Value::kReverse);
}
} else {
wasAPressed = false;
}
}
}
Please read:
http://www.cplusplus.com/doc/tutorial/classes/ 