A simple class for controlling a DigiSpark RGB LED via USB using Python.
The arduino
package in this repo was borrowed from DigiSpark Example Programs. This all came about when I was working on a headless Raspberry Pi based project (Pi-Nova-5) and wanted to use the DigiSpark LED as a status indicator.
The two external Python dependencies are included in the requirements.txt
file. The webcolors package can be installed via pip
. To install the pyusb package, follow instructions in that repo. After that, load the DigiUSB→DigiBlink
example sketch onto your Digispark using the DigisparkArduino IDE.
Once everything is installed, simply plug the DigiSpark into a USB port on your computer and...
from led import LED
my_led = LED()
# make it red
my_led.on('red')
# make it blue
my_led.on('blue')
# make it green
my_led.on('green')
# blink red 3 times
my_led.blink('red', 3)
# blink blue 5 times
my_led.blink('blue', 5)
# blink green 10 times
my_led.blink('green', 10)
my_led.off()