soft toggle circuit

Thread Starter


Joined Apr 16, 2011

I'm using this circuit to soft toggle an arduino on and off. It works fine. The P mosfet turns on when the button is pressed, which turns on the N mosfet, which then latches the P mosfet on even after the button is released. A subsequent long press on the button brings the gate of the N mosfet low, once the 10uF capacitor has discharged.

I would like to be able to notify the arduino that the button has been pressed the second time, so that it can display a momentary "turning off" message. If I originally thought to set a pin as input_pullup and attach it to the button switch, so that it's pulled low when the button is pressed. However, this has the effect of keeping the circuit on permanently. The alternative is to configure it as a simple input, but i can't see anywhere on the circuit that is going to go momentarily high when the button gets the second press. What's the best way to achieve what I want please?



Joined Dec 2, 2017
I don't use Arduino, but if I wanted something like that with the platform I use I might try tying the switch to a high impedance GPIO that starts and stops a timer, then if the timer reaches its period, it sends the message.

But if that would be too late then I might try a counter instead.

Probably would use a isr instead of polling, depending...

Of course I might have to try many different things until I got what I needed.


Joined Dec 2, 2017
After some more thinking about it, I realized you wouldn’t need a counter because the first press is before the micro is started.

So a simple button press detection should work with a isr.