Circuit for using 1 push-button for on/off and also for user input (with micro) - Page 1
Forum section: electronics / projects

author: DigitalDesigner
author_rank: Contributor
timestamp: June 04, 2025, 03:53:20 am
content: Hi,where can I find a simple circuit with one push-button:- turns on the system- the micro latches it on- the micro can turn it off (when for example a long press or other events occur)- the micro detects every switch interaction so short presses can be used for simple menu navigationThe micro can use either the same pin for latching and detecting pushbutton state or - alternatively - two separate pins.Thank you

author: Psi
author_rank: Super Contributor
timestamp: June 04, 2025, 04:36:43 am
content: Here's something i made once that seems to work fine.PWR_HOLD comes from MCU output.PWR_ENABLE is not used, just turns the thing on when connecting external programmer.When you hit any button it pulls PWR_ENABLE up temporarily as it charges up C4/C5.That turns on Q3 for enough time that the MCU starts up and holds on Q3 through D5 from the PWR_HOLD output.Buttons all continue to be readable by the MCU when awake.When the MCU wants to power off it simply turns off PWR_HOLD and Q3 turns off from R18.You might need to tweak C4/C5 if your MCU takes ages to startup. I have MCU set to 4ms startup delay time but some are longer.It's probably not the simplest solution, but it worked for me to get ultra low off power current and still wake up from button press and also use the buttons for UI

author: reboots
author_rank: Regular Contributor
timestamp: June 04, 2025, 04:42:53 am
content: I've done this with an AVR microcontroller. There was no circuitry to speak of beyond hardware debouncing of the pushbutton. The button was wired to a pin which could register an interrupt and wake the AVR from sleep mode. The AVR was never powered completely down, only asleep with I/O configured for very low current draw.The C code did all the work. As I recall, I used an integer as a counter which incremented at a set rate while the pushbutton was pressed and decremented at the same rate while it was released. Other sections of the code watched the counter and triggered various modes depending on the value reached in each direction. For the configuration menu I used a switch statement. This was a very successful system with a simple, intuitive UI. Unfortunately I can't share the code. From memory:1. Hold for 1.5 seconds to turn on2. If held for an additional 2 seconds after power on, enter configuration mode3. Short presses control operating functions4. Extended press (3 seconds) enters sleep modeConfiguration mode:1. Short press cycles through configuration submenus2. Long press enters submenu, short press configures, long press exits submenu3. Extended press (3 seconds) stores menu values to EEPROM and watchdog restarts MCU with new valuesI've looked at ways to trigger microcontroller startup from total power off with a momentary pushbutton which is then used for UI, but IIRC decided that was a little more complex. I believe there was a P-FET involved for power switching. The system I described above had over a year of standby runtime, so power didn't end up being an issue.

author: Psi
author_rank: Super Contributor
timestamp: June 04, 2025, 04:45:41 am
content: Yeah, if you only need 1 button to wake up its easier to do.I needed 4 buttons which all wake up the system but are readable individually once awake, so it made things more complicated.

author: Someone
author_rank: Super Contributor
timestamp: June 04, 2025, 05:08:21 am
content: Quote from: Psi on June 04, 2025, 04:45:41 amMany modern micros have assignable (or at least multiple) interrupt pin mapping, or even wake on any logic change of a whole port. As reboots expands on, depends on the specific goals of the project and the trade off between more external parts vs the lowest sleep mode of the micro.

author: Psi
author_rank: Super Contributor
timestamp: June 04, 2025, 05:16:13 am
content: Quote from: Someone on June 04, 2025, 05:08:21 amSorry, i shouldn't have used the word wake.I powered off the MCU entirely with a pfet for extra power savings.

author: ataradov
author_rank: Super Contributor
timestamp: June 04, 2025, 05:37:22 am
content: My version. It uses two GPIOs, one for reading the button state and one for latching the power.

author: Someone
author_rank: Super Contributor
timestamp: June 04, 2025, 05:50:27 am
content: Quote from: Psi on June 04, 2025, 05:16:13 amPlenty of silly semantics to dig through, a micro in "power down" that has zero dynamic operation (all static logic) that will start from the reset vector when a pin is changed. Not really wake either. When chasing really low power unexpected paths can end up providing enough power to keep a micro running or in some ill defined state, turn on the brown out detector and there goes the savings!Quite a bit of engineering to get this stuff optimised on a system level.

author: RoGeorge
author_rank: Super Contributor
timestamp: June 04, 2025, 07:21:04 am
content: Quote from: DigitalDesigner on June 04, 2025, 03:53:20 amOne such example is in the T4 universal tester (LCR/ESR/transistor-meter):Schematic fromhttps://www.eevblog.com/forum/testgear/$20-lcr-esr-transistor-checker-project/msg709934/#msg709934

author: DigitalDesigner
author_rank: Contributor
timestamp: June 04, 2025, 10:06:30 pm
content: Thank you all for the information and the schematics. Very useful!