DO NOT USE
use On/Off Switch instead
On some projects, I want a power indicator and a reset switch. Adafruit's Momentary Rugged Metal Push Button with Blue LED contains both of these features. My first, second and third attempts were way too complicated. This version makes things much simpler
For Raspberry Pis used by my family, the momentary push button allows them to reboot in an orderly manner, and reboot without my assistance. Kodi will lock up at times, and a reboot fixes most problems.
For this guide, I am using a Raspberry Pi-based media center running Kodi on OSMC.
I've tried several different momentary switches. Adafruit's Rugged Metal Push Button with Blue LED is very cool. Any momentary push button can be used. However, the momentary button was a poor choice. I should have used an on/off switch. I've ordered some from Adafruit
This is one of two guides for a Kodi/OSMC hat for the Raspberry Pi. The final hat will have a fan, this momentary push button and an Infrared (IR) Receiver.
Random comments:
Adafruit has some excellent "instructables", but I they are difficult to find. In google, try:
♣search-terms♣ inurl:https://learn.adafruit.com/
rugged led ring inurl:https://learn.adafruit.com/
Fritzing is an amazing tool for breadboarding
Step 1. Ada Fruit Ring LED
I use the ring LED is a power indicator. If the raspberry pi is powered and running then the Ring LED should be lit (or blue). If there is no power or the raspberry pi is shut down, then the ring LED should be off.
Step 2. Ring LED Connections
A breadboard allows me to experiment with the circuit until it works. Male-to-female jumper wires and connecting wires that come with breadboards make this process easier. Male-to-female jumper wires connect the breadboard to the raspberry pi.
The two outer connections on the Ring Push button control the Ring LED. The ground terminal is connected to the Raspberry Pi ground. Ground is (-). And GPIO 24 will be connected to the positive terminal (+).
With 2 yellow and 1 white female-to-female jumper wires, cut off one of the two headers from each cable.
When using colored wire, I try to use white for ground, black for power and Y/R/B/G for GPIO pins
Strip 1/4" inch from the cut end of the wire.
Insert each wire into an opening on the appropriate pin on the Rugged Push Button. The white wire goes into the minus (-) pin. One yellow wire goes into NO1, and the other yellow pin goes into the positive terminal (+)
Solder the wires to the Rugged Push Button.
Connect + of Rugged Push Button to GPIO 24
Connect NO1 to Rugged Push Button to GPIO 23
Connect - to Rugged Push Button Ground
Step 3. Utility software for python
On OSMC, the Ring LED software requires the rpi.gpio package. rpio.gpio is installed by default on raspbian.
The following commands download, build and install rpi.gpio
$ sudo apt-get update
$ sudo apt-get install python-pip python-dev gcc
$ sudo pip install rpi.gpio
Step 4. Get Push Button Script
Open a terminal and log into the Raspberry Pi
In the terminal window, get the LED and PushButton script on the Raspberry Pi
$ wget https://raw.githubusercontent.com/dumbo25/momentary-reset/master/pushButton.py
Change the permissions on the filea
$ sudo chmod 755 pushButton.py
$ sudo chown osmc:osmc pushButton.py
Step 5. Start the script on boot
Get systemd services to start the script on boot:
$ wget https://raw.githubusercontent.com/dumbo25/momentary-reset/master/pushButton.service
Copy the script to the right directory:
$ sudo cp pushButton.service /lib/systemd/system/.
$ sudo systemctl daemon-reload
$ sudo systemctl enable pushButton.service
$ sudo reboot
The Ring LED should light up!
Push the button twice in 2 seconds to reboot, push twice about 10 second apart and the system will shutdown