Add a status LED to your Raspberry Pi

Alex Ellis
Level Up Coding
Published in
6 min readApr 21, 2020

--

In this tutorial, I’ll show you how to add an LED to your Raspberry Pi so that you can show the status of an external system or API. The board we’ll use only costs a few dollars and has 8 programmable RGB LEDs making it a versatile and economic option.

Above: My IoT demo for Dockercon 2016 showing a temperature sensor status — green for within range and red for an alert.

We’ll start off by installing Golang (Go) and then downloading a library from Git which can control the Blinkt. Then we’ll try one or two samples before going on to finally set a colour to represent the status of an external API.

Why Go and not Python? There are libraries available for both languages, and after you’ve completed the tutorial, if you want to try Python, see the Blinkt repo from Pimoroni.

Part 1 — the setup and installation

Pre-reqs:

  • Blinkt! from Pimoroni — a cheap and versatile RGB LED add-on
  • Raspberry Pi 2/3/4 — we’ll be using Go and its compilation is much faster on these boards than on an RPi Zero
  • Rasbpian Lite or Raspbian Desktop flashed to your SD card, use etcher.io to write the image.
  • SSH access enabled (instructions will follow)

Power-off and install the Blinkt!

Take note of the curved edges of the Raspberry Pi and the add-on board. Make sure they both face in the same direction.

Installation on RPi3

Once connected, it’s time to power on the RPi. I prefer to work over Ethernet, but if you have WiFi configured that will also work fine.

Connect to the Raspberry Pi over SSH

SSH isn’t turned on by default, so create a file named ssh in the /boot/ partition of your SD card, or use raspi-config to enable it. On a Mac, I simply sudo touch /Volumes/boot/ssh.

We’ll run all of these commands over ssh, so run ssh pi@raspberrypi.local or replace “raspberrypi” with the hostname you set. If you cannot connect…

--

--