Soft Latch Power Switch (Ardweeny)

Today I wanted to upload a design I created for a soft latch power switch.  It was used to power a Solarbotics Ardweeny, though you could use it for just about any microcontroller.  If your microcontroller requires something other than +5V input, you may need to change the linear voltage regulator used, but the rest of the circuit should work fine.  Everything here was powered from a single +9V battery.

For those who do not know what a soft latch power switch is, it allows a single button to perform three tasks - power on the microcontroller, act as an input to the microcontroller, and power off the microcontroller.  Additionally, the soft latch power switch allows the microcontroller to power itself off.  This is excellent for situations where a user may not power the device off, but you need to conserve battery.  If no input is received within a desired amount of time, the microcontroller simply powers itself down.

For this project you will need:
- 9V battery
- 9V battery leads
- P-Channel MOSFET (PN: STP12PF06)
- NPN Transistor (PN: 2N3904TFR)
- 2x Rectifier Diode (PN: 1N4002)
- 5V Linear Voltage Regulator (PN: L7805ABV)
- Momentary Switch
- 3x 100k resistors
- 0.10 uf Capacitor (PN: UKL1H0R1KDDANA)
- 0.33 uf Capacitor (PN: UKL1HR33KDDANA)
- Microcontroller (Arduino)
- Proto-board

Construction:  Connect everything on your proto-board as shown in the schematic.  Note that 'A0' and 'D0' connect to the microcontroller, as well as the +5V and ground (on the right of the schematic).  If desired, the +9V output on the top right can be connected to any additional circuits required.  Otherwise, only connect it to the voltage regulator.

Operation:  When the power is off and the switch is pressed, the P-FET is activated and +9V is supplied to the linear voltage regulator.  The regulator then supplies +5V to the microcontroller and it will turn on.  It is important that your software immediately sets pin 'A0' to a high output.  If done properly, the voltage on this pin will activate the NPN transistor and latch the power circuit on.  While powered on, the pin 'D0' can be setup and used as an input.  In my prototype, when the switch is momentarily pressed, the system responds by playing a beep.  If the switch is held down for at least 2 seconds, the microcontroller plays a longer beep and sets pin 'A0' to a low output.  This will release the latch, and the microcontroller will be powered off when the switch is released.  If the switch is not pressed for 30 seconds, the microcontroller will automatically shut down.

Below you will find a video of my prototype and some Arduino code.  In the video, everything is attached to a protoboard and you can see how it works.  As shown in the picture, however, it can all be soldered to a more permanent board in a nice and compact form.  I didn't have a lot of space in the device I put this in, so it worked out perfect.  The code provided should get you pretty well started.  Enjoy!

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Arduino Contest

Participated in the
Arduino Contest

1 Person Made This Project!


  • Made with Math Contest

    Made with Math Contest
  • Multi-Discipline Contest

    Multi-Discipline Contest
  • Robotics Contest

    Robotics Contest

16 Discussions


2 years ago

Does anyone know the power consumption of this circuit when it is switched off?


2 years ago

What should I changes if I used it on 3.3v arduino/ attiny85?
I want to make a door sensor that powered on when the door open and keep activate for a while (15 - 30s) to send information via Internet although the door already closed. And just before power off, system will check whether current door status is still open or already closed. If still open the system will send the status back and recheck every 5s until the door closed.


3 years ago

I use a similar circuit, but add a 2.2uF capacitior from the collector to emitter of the NPN to keep the power on long enough for the micro to power-up and assert A0

In my circuit I use a FET instead of the NPN, but the principle is the same.

My circuit also allows for either battery or mains power, by using back to back P-Fets and a couple of extra interlocking components.

Power consumption in OFF state is depends on

i) leakage through the p-fet when off , (say IRF7410 <1uA at 25degC more at higher temps. IRF7410 has On resistance of <7mOhms)


ii) leakage through the 100k and NPN (say <15nA (Icbo) for BC546 )


iii) leakage through the 100k and micro processor input

You can delete iii) not really needed, by removing the 100K from 9V to D0 .

So Off current is say <1uA


4 years ago on Introduction


what is the power consumption in OFF state of this circuit?



Reply 5 years ago on Introduction

You need the diodes for Arduino to be able to read the Button state.

Without the diodes it will read low when the button is not pressed because of the npn pulling low and it will read low again when the button is pressed so there will be no state change.


Reply 4 years ago on Introduction

Thats what D2 is for. It will separate the Mosfet pulled low from the button. but why is is there a D1? It seems to be just incresing the input to the uC by 0.7V


5 years ago on Introduction

The first 100K pullup will draw current in the off state via D0-->Arduino-->GND.

It can be easily fixed by connecting the 100K pullup to any point after the P-FET.

Maybe even to a 5v rail of the Arduino.

Overall a nice, simple circuit that works and has low parts count. is a very low Vgs mosfet. It is a good choice if you are trying to make a low power device.


5 years ago on Introduction

Just wandering,how much this circuit draws in off state ?

Both N-fets and P-fets should work fine, though you will need to change the circuit around a bit to ensure the correct voltages are applied to the gate.


5 years ago on Introduction

I have been trying to find a simple soft latch power switch for a while. Your build seems to fit the build, but I don't a P-MOSFET. Is it possible to use a PNP instead?


5 years ago on Introduction

Great ! I'm usign that in my next project. I'm not too sure about sending D0 as an input to my arduino, since the pullup is tied to 9v,better drop the pullup and let the internal pullup do the work.