How to create a circuit that does high, medium and low with a single push button ...

Thread Starter

EasyGoing1

Joined Dec 10, 2016
14
So I'm not sure how to describe what I'm wanting to do other than to refer to any modern LED flashlight that has a single pushbutton where each push cycles through different light intensities then back to OFF mode.

How do they achieve that functionality with a single pushbutton? Is it a common IC or something that they use?
 

MrChips

Joined Oct 2, 2009
23,507
I can be done with hardware that registers machine states, i.e. with flip-flops.
It can also be achieved with a small low pin count MCU.
 

crutschow

Joined Mar 14, 2008
27,172
It's likely done with a small microprocessor.
It could also be done with a CD4017B digital IC (LTspice simulation of example circuit below).
If the circuit needs to power up in the off state, some additional circuitry is required.

1611067884024.png
 
Last edited:

Thread Starter

EasyGoing1

Joined Dec 10, 2016
14
It's likely done with a small microprocessor.
Curious ... I can definitely visualize this with something like an attiny ... but what I can't seem to picture is how the button could first power it on, while subsequent presses of the same button trigger the code to generate the desired behavior on some GPIO pin(s). Unless there is a way to somehow connect the mp to power on the first press, then something switches so that it keeps power latched on the mp and the button somehow is re-purposed during power on to signal a pin that triggers code... having a hard time with that but I would have to imagine that it's possible.
 

MrChips

Joined Oct 2, 2009
23,507
MCU is placed in ultra-low power mode consuming less than 1μA.

The pushbutton generates an interrupt on a GPIO pin and wakes the MCU out of low power (sleep or stop) mode.
From there on software can detect any sequence of button presses, for example, 1st, 2nd, 3rd press, short press, long press, double and triple clicks, etc.

Common practice is to revert to low power mode on a long press or if the device has been idle for n seconds.
 

Thread Starter

EasyGoing1

Joined Dec 10, 2016
14
MCU is placed in ultra-low power mode consuming less than 1μA.

The pushbutton generates an interrupt on a GPIO pin and wakes the MCU out of low power (sleep or stop) mode.
From there on software can detect any sequence of button presses, for example, 1st, 2nd, 3rd press, short press, long press, double and triple clicks, etc.

Common practice is to revert to low power mode on a long press or if the device has been idle for n seconds.
I like this... the options on functionality with a mp are almost limitless!
 
Top