Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Bounce Library

  1. #1
    Junior Member
    Join Date
    Nov 2018
    Posts
    16

    Bounce Library

    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.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,758
    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");
        }
      }

  3. #3
    Junior Member
    Join Date
    Nov 2018
    Posts
    16
    Thanks I'll try that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •