Arduino Self Shutdown (Arduino: cutting off your own power supply by software)

How it works: By pressing a push-button, the Arduino will be energized and therefore will turn on, and after 5 seconds it will auto-turn off, by cutting its own power.

With this small project I would like to demonstrate how you can do the Arduino (or other mcu) turn off itself via software. I am not refering about a "Deep Sleep Mode" of the mcu, but cutting off the circuit power totally. Thinking of applications, we can imagine for example, a process of "Time Out" where when detecting inactivity on the device, it turns off completely. Or a button that once pressed, turns on the circuit, and turns itself off as soon as a task is completed.

Anyway, there are several applications which can use the method demonstrated here. Basically, the concept of the idea is to keep the circuit with the power cutted off, until a push-button be pressed to short the circuit. Thus, so the microcontroller is connected, your first action is to trigger the Mosfet which also will short the circuit, making the push-button been unnecessary from this time. Therefore, both components, Mosfet and push-button must be connected in parallel.

In this example, the Arduino will remain turned on for 5 seconds, and then after 3 beeps, it will be turned off by itself.
I used the pin 7 of the Arduino to drive the Mosfet, and keeping it HIGH the circuit remains on. And consequently, to turn off the circuit completely just change the state of the pin 7 to LOW.

Note:
- The power supply goes directly to the 5V Pin on the Arduino board, and itīs not using USB or the other external power in.
- In this example, once the circuit is triggered, it will remain on for 5 seconds, and then after 3 beeps the Arduino self-turn off.
- I would like to emphasize that the Mosfet can be easily replaced by other components, such as SSR, Relay, Transistors , opto-couplers, among others.

Schema using a Mosfet:


Schema using a Relay:





Download Source Code







I hope you liked it! And please, feed back through: egzola@gmail.com