Raspberry Pi - use blinkt shield for status LEDs
A while ago I bought a Pimoroni blinkt shield. Today I started usint it as a status LED.
First step is to install the library. For me - using archlinuxarm - the "simple" installer from the tutorial doesn't work - so I installed blinkt via pip:
Now test if everything works:
import time import blinkt blinkt.set_brightness(0.1) while True: for i in range(8): blinkt.clear() blinkt.set_pixel(i, 0, 255, 0) blinkt.show() time.sleep(0.5)
And finally a real example - showing the status of a github-action build on the first LED:
import time import requests import blinkt blinkt.set_brightness(0.05) while True: r = requests.get("https://github.com/mlugs/website/workflows/github%20pages/badge.svg") # led_num, r, g, b led_color = (0, 255, 255, 0) # yellow if r.status_code == 200: if "passing" in r.text: led_color = (0, 0, 2, 0) else: led_color = (0, 255, 0, 0) blinkt.clear() blinkt.set_pixel(*led_color) blinkt.show() time.sleep(60)
/etc/systemd/system/blinkt-status.service
:[Unit] Description=blinkt LED status [Service] ExecStart=python /root/blinkt_github_actions.py Restart=on-failure [Install] WantedBy=multi-user.target
Enable the systemd service with: systemctl enable blinkt-status