If you need an Arduino to shut off from within your Sketch, this is the solution.
We will explore wiring the Pololu Pushbutton Power Switch, programming the Arduino to shut off the power, and making the unit “power on” only.
The Pololu Pushbutton Power Switch comes in two versions – the SV version geared towards 4.5V-20V range, and the LV which specifies 2.5V-7.0V range. I will use a 9V battery for this demo, and thus the SV version of the power switch.
Webpage for the Pololu Pushbutton Power Switch
Step 1: Getting familiar with the Pololu Power Switch
It also sports 2 connectors for a momentary contact switch, allowing you to use the provided switch directly on the board, or solder your own leads for a switch (or switches) separate from the unit.
Step 2: Setting up the Pololu Power Switch
Attach the 9V battery leads Red to VIN, Black to GND on the Pololu Power Switch
I used a 2.1mm male power jack to plug directly into the Arduino, which regulates the voltage to something the Arduino can handle easily. GND on the Pololu Power Switch goes to the outer connector on the power jack, and VOUT (Red) goes to the inner connector. (See photo)
Pressing the momentary contact switch should power up the Arduino. A second press should turn it off. This is the same behaviour as a standard On/Off switch.
You can choose to either solder the included momentary contact switch to the PCB, or wire it separately to the Breadboard. Wiring it separately means you can use a different momentary contact switch, and/or mount it to your project cabinet. In the early shots of this project, I mounted the momentary contact switch to the PCB for simplicity of the photos, but in the later shots the momentary contact switch is mounted on the Solderless breadboard.
Step 3: Connecting the Pololu Pushbutton Power Switch to the Arduino, Upload Sketch
The Pololu Power Switch will turn off the power anytime it gets a HIGH signal on the OFF pin. This simplistic Sketch does nothing more the wait 5 seconds before turning off the power. The same concept applies in any Sketch you are working on – when the conditions you have decided on are met…Set the pin connected to the Pololu Power Switch’s OFF connector HIGH, and the power gets shut off.
You can connect the Pololu Power Switch to any of the Arduino Output pins, but you will need to modify the Sketch to use the same pin.
The photo shows the momentary contact switch mounted on the breadboard, and the OFF line coming from the Arduino