View Single Post
  #6   Spotlight this post!  
Unread 09-02-2017, 22:01
charlier999's Avatar
charlier999 charlier999 is offline
Registered User
FRC #1662 (Raptor Force Engineering)
Team Role: Programmer
 
Join Date: Feb 2017
Rookie Year: 2013
Location: Lodi, CA
Posts: 18
charlier999 is an unknown quantity at this point
Re: Pneumatics code problems.

Quote:
Originally Posted by euhlmann View Post
Code:
bool wasAPressed = false;

// then in in 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;
}
The one problem with this code is that when i press the button longer than 1/50th of a second(50 cycles per second the rio reads the code), it hastily switches back and forth between on and off. Is there any way of fixing the problem or do i just need to have extremely fast fingers for that button.

Thx.
Reply With Quote