– How do long-press switches or buttons work?

84 views

In my mind, pressing or tapping the switch makes the contacts and completes the circuit. What’s happening when keeping the button pressed? And how does the switch do something different when long-pressed?

In: 1

Anonymous 0 Comments

* Buttons that can be “long pressed” complete a circuit that is monitored by a microprocessor.
* When it first sees the circuit connected, it starts a timer.
* When it sees the circuit open back up, it stops the timer.
* If the timer is less than the “long press time” it does action A.
* If the timer is more than the “long press time” it does action B.
* BONUS:
* Mechanical switches actually “bounce” when they make contact so the processor has to do some extra processing to figure out if the user pressed the button once or more than once.
* It is mostly done with timing. For example, the button might bounce 10,000+ times in less than a second.
* The processor knows that a human can’t press the button the fast so it assumes it was one press.