I’m using this circuit to turn on and off an Attiny167 and an LED driver with the push of a micro switch.


My circuit is powered by an 8.4V battery.

In the “load” part of the circuit there’s a voltage regulator to 5V, the LED driver and the Attiny.

It works pretty well, and with a HIGH signal from the MCU I can also shut down the circuit without needing to press the button.

I’d like to be able to, by using another output pin on the MCU, keep this latching circuit always ON, and keep it ON no matter if the button is pressed or not, until I choose to.

What should I change in this circuit (if possible) to be able to do that?

  • \$\begingroup\$ With the above circuit, you can use the switch to unlatch it? I'm not seeing it. \$\endgroup\$ Jun 14, 2021 at 20:29
  • \$\begingroup\$ Not the solution you're looking for, but... consider connecting the push button directly to a GPIO pin, have the attiny directly control the P-MOSFET (via the N-MOSFET), use a microamp quiescent LDO regulator for the attiny, run the attiny in deep sleep mode when the circuit is "off", and put all the push button logic in the attiny. Then the logic can be as complicated as you want. Example low-Iq LDO regulator: mouser.com/datasheet/2/792/rx5rl-ea-1770720.pdf \$\endgroup\$
    – ErikR
    Jun 14, 2021 at 20:30
  • \$\begingroup\$ @CristobolPolychronopolis - yes you can use the switch to cut the power because the cap will not be charged (very much) when the central N-MOSFET is on. \$\endgroup\$
    – ErikR
    Jun 14, 2021 at 20:31
  • \$\begingroup\$ @CristobolPolychronopolis your solution worked perfectly! Thanks. This is a simulation showing it working! tinyurl.com/yh77oja8 \$\endgroup\$
    – Rodrigo
    Jun 15, 2021 at 14:39

2 Answers 2


I see it now, thanks. You could add a second NFET in parallel with the first one, but with the gate driven by the processor. This would keep the PFET conducting even with the first NFET momentarily turned off.

  • \$\begingroup\$ You could also use an NPN to level shift logic level “1” to pull down input gate instead of logic level FET. \$\endgroup\$ Jun 14, 2021 at 20:47
  • \$\begingroup\$ True, but I have a zillion small diodes to use up. \$\endgroup\$
    – AnalogKid
    Jun 14, 2021 at 22:23

This would be a lot easier if the schematic had reference designator.

As I understand it, there is only one microcontroller. The pushbutton can turn it on by supplying power through the circuit, and once it is powered up it can turn itself off with the off signal. To give the uC the ability to override the pushbutton, add 1 diode.

From a second output pin, connect a small signal diode cathode to the uC pin, and the anode to the 10K/100K node. With this connection, the uC can hold the pass transistor gate low enough to keep that transistor on.

  • \$\begingroup\$ That would require the micro pin to survive having 8V on it... \$\endgroup\$
    – brhans
    Jun 14, 2021 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.