Introduction: Add Adafruit's Ring LED Momentary Switch to Raspberry Pi

As part of my cord cutting system, I want a power indicator and a reset switch on 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.

This is the first of several instructables, which form the basis of a Kodi/OSMC hat for the Raspberry Pi.

In each instructable, I will get part of the hat to work and I think each piece of the hat is useful by itself.

Step 1: Gather Parts

Parts specific to this instructable:

  • Rugged Metal Push Button with Blue LED Adafruit $4.95
  • Short breakaway pins Adafruit $4.95

Reusable parts and tools (prices in USD):

  • Breadboard Fry's $7.99
  • Breadboard wires Fry's $7.99
  • Male to Female Jumper Wires Fry's $3.99
  • MacBook Pro (a PC could be used)
  • Raspberry Pi 3 Element14 $35
  • 5.2V 2.1A USB Power Adapter from Amazon $5.99
  • Micro USB to USB cable 3ft from Amazon $4.69
  • Case from Amazon $6.99
  • SanDisk Ultra 16 GB microSDHC Class 10 with Adapter (SDSQUAN-016G-G4A) from Amazon $8.99
  • Solder, Solder Station, Tip Cleaner
  • TV with HDMI port, USB keyboard, USB mouse, HDMI Cable


  • Text enclosed in spades, such as, ♣replace-this♣, should be replaced with an actual value. Of course, remove the spades.
  • The Raspberry Pi should be set up and running Kodi/OSMC
  • Adafruit has some excellent "instructables", but I they are difficult to find. In google, try:
    • ♣search-terms♣ inurl:
    • rugged led ring inurl:
  • Fritzing is an amazing tool for breadboarding

Step 2: Ring LED

In my applications, 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.

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 in series with a 330 Ohm resistor. Ground is (-). And GPIO 24 will be connected to the positive terminal (+).

Utility software for python

The Ring LED software requires the rpi.gpio package. The following commands download, build and install rpi.gpio

$ sudo su
# apt-get update
# apt-get install python-pip python-dev gcc
# pip install rpi.gpio
# exit

Exit returns to $ prompt

Ring LED Software

Turn the Ring LED on

$ sudo nano /usr/local/bin/

and edit to be:

#!/usr/bin/env python

import RPi.GPIO as GPIO
import subprocess
import argparse
parser = argparse.ArgumentParser()

group = parser.add_mutually_exclusive_group()
group.add_argument("-l", "--light", action="store_true")
group.add_argument("-o", "--off", action="store_true")

# Disable warnings

# turn on gpio pin 24
GPIO.setup(24, GPIO.OUT)
args = parser.parse_args()
if args.light:

Type CTRL-o, CTRL-x ENTER to save the file and exit nano editor

Change the permissions on the file

$ sudo chmod 755 /usr/local/bin/

Create a start script:

$ sudo nano /etc/init.d/

and edit to be:

# Provides:          scriptname
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.

# Starts and stops
# Directory: /etc/init.d/
# Permsissions: chmod 755 /etc/init.d/

# Start or stop
case "$1" in
    /usr/local/bin/ --light &
    /usr/local/bin/ --off &
    echo "Usage: /etc/init.d/ {start|stop}"
    exit 1

Type CTRL-o, CTRL-x ENTER to save the file and exit nano editor

Change the permissions on the file

$ sudo chmod 755 /etc/init.d/

Register the script to run on boot

$ sudo insserv 

Start the script

$ sudo /etc/init.d/ start

The Ring LED should light up!

Step 3: Reset Switch

Reset Switch

In general, my Raspberry Pis run all the time. A Raspberry Pi 3 consumes very little power.

Ideally, I would like a power switch to safely shut down the pi, by calling sudo shutdown -h 0 before cutting off the power. However, implementing a power switch is more complicated and will be rarely used.

This is a reset switch, basically, it restarts the Raspberry Pi.

Solder two pins to Raspberry Pi 3

On the Raspberry Pi 3, find the Run holes - see image, box in yellow. The Run holes are near the gpio header.

Remove all cables (power, HDMI, ethernet, etc.) and the Micro SD card from the Raspberry Pi.

From the bottom of the board, solder two short breakaway male pins through the Run holes.

Connect everything back together and make sure it still works.

Connect N01 (normally open) on the momentary switch to one of the Run pins, and C1 to the other Run pin. NC1 (normally closed) is not used.

Press the button, and the system should reboot!