https://github.com/projectweekend/digispark-rgb-led
A simple class for controlling a DigiSpark RGB LED via USB using Python
https://github.com/projectweekend/digispark-rgb-led
Last synced: 12 months ago
JSON representation
A simple class for controlling a DigiSpark RGB LED via USB using Python
- Host: GitHub
- URL: https://github.com/projectweekend/digispark-rgb-led
- Owner: projectweekend
- Created: 2014-03-01T20:52:26.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-03-01T21:24:35.000Z (over 12 years ago)
- Last Synced: 2025-02-01T19:29:57.327Z (over 1 year ago)
- Language: Python
- Homepage:
- Size: 203 KB
- Stars: 1
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
DigiSpark-RGB-LED
=================
A simple class for controlling a [DigiSpark](http://digistump.com/products/1) [RGB LED](http://digistump.com/products/3) via USB using Python.
The `arduino` package in this repo was borrowed from [DigiSpark Example Programs](https://github.com/digistump/DigisparkExamplePrograms/tree/master/Python/DigiBlink/source/arduino). This all came about when I was working on a headless Raspberry Pi based project ([Pi-Nova-5](https://github.com/projectweekend/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](https://pypi.python.org/pypi/webcolors) package can be installed via `pip`. To install the [pyusb](https://github.com/walac/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...
## Create an LED instance:
```
from led import LED
my_led = LED()
```
## Turn the LED on:
```
# make it red
my_led.on('red')
# make it blue
my_led.on('blue')
# make it green
my_led.on('green')
```
## Blink the LED:
```
# 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)
```
## Turn the LED off:
```
my_led.off()
```