Auto Power off with 2N2222

Hi, well its been a long while since i have done programming or electronics but loving playing with my uno!

I wanted to create a simple circuit that keeps power on to the Arduino until a digital pin goes low. so this what i was trying.

press switch supplies power to the UNO. the UNO boots up and raise D6 out pin HIGH, this is connected to the base of the 2n2222 via a 1K resistor.

the 2N2222 maintains the power when the switch is released until in code the Pin connected to the base is lowered.

Arduino is powered via 9V battery on VIN.

I can use the 2N2222 to switch an LED on and off, but it is controlling the uno its on all the time. the 2N2222 i believe is rated at 30V 800mA so should not be breaking down.

So not sure what i'm doing wrong!

Sorry for the lack of a circuit diagram I have not found what you all use to do them yet!

I_Need_Help2: Sorry for the lack of a circuit diagram I have not found what you all use to do them yet!

Pen, paper, digital camera. If possible, set the camera to 1024x768 or lower resolution. When taking the picture, back up a bit then use zoom to frame the paper.

To post the image, click [u]Reply[/u], click [u]Attachments and other options[/u], click [u]Browse[/u], select the image, click [u]OK[/u]/[u]Open[/u], click [u]Post[/u].

Do you have a pull down @ the base as well? Otherwise the base will float high is arduino isn't powered.

The simplest way to implement this is with the polulu switch module. polulu push on/push off switch It will allow you to power on the device with a button press, push it again, it powers off... and.. it has a pin which will allow you to turn it off from an arduino pin. All for less than $7.00.

The Polulu switch is interesting but I want to do it without another circuit board and cannot see why a simple NPN doesn’t do it!

Well I have now found Fritzing and drawn what i think i have.

the Led is controlled fine but when i add the GND link (green wire) it comes on and the board powers up without the switch being pushed!

I just know i have done something stupid, but i need to start somewhere!

That circuit isn't going to work, but you can do it with 2 transistors. Use a PNP transistor to switch the +ve side of the battery (emitter to battery +ve, collector to Arduino Vin or barrel jack). Then use an NPN transistor driven by an Arduino output pin to drive base of the PNP transistor, not forgetting the current limiting resistors.

Thanks I will give the 2 transistor approach a go, now off to buy some online!

Is there no way of achieving this with a single transistor? or other cheap device, could a Thyristor be used?

I would like to try and achieve it with the least amount of components possible, any alternative approaches?

Sleep mode is not an option as there is another board powered from the arduino's +5V which needs to be off too...

The fundamental issue is that switches made from transistors invert, so that you need another inverter somewhere that isn't powered down. For instance you could high-side switch with a PNP or p-FET driven from a 74HC14 inverter, so long as the inverter remains powered up to pull the base high when the load is powered down.

With an NPN or n-FET on the low side the powered down load is necessarily at 5V, so you need to invert that to get 0V for the base/gate of the switch.

One flexible way to do a power switch is use a CMOS set/reset flip-flop driving a p-channel FET high-side switch. This gives a two inputs, one to power up and one to power down.

Hi Mark thank you for taking the time to explain it to me I do appreciate it.

"One flexible way to do a power switch is use a CMOS set/reset flip-flop driving a p-channel FET high-side switch. This gives a two inputs, one to power up and one to power down."

Sounds very interesting would you be able to point me at an example circuit?

thanks

google "flip flop"?

thanks, after finding a lot of footwear ::) I found this very helpful Page

http://www.mosaic-industries.com/embedded-systems/microcontroller-projects/electronic-circuits/push-button-switch-turn-on/latching-toggle-power-switch

Thanks