Bounce Library

Status
Not open for further replies.

757

Active member
Hello does anyone know which Bounce example is best to use to make a pushbutton act like a toggle switch? I am using a teensy 2.0++ for XPlane 11.
 
You need more than just the Bounce library. You will also need to add some code to remember the emulated toggle switch's position.

Something like this...

Code:
  button1.update();
  if (button1.fallingEdge()) {
    if (toggleState == true) {
      toggleState = false;
      Serial.println("Toggle switch is off");
    } else {
      toggleState = true;
      Serial.println("Toggle switch is on");
    }
  }
 
Status
Not open for further replies.
Back
Top