Skip to content

Instantly share code, notes, and snippets.

@bensonk
Created February 26, 2013 08:13
Show Gist options
  • Save bensonk/5036891 to your computer and use it in GitHub Desktop.
Save bensonk/5036891 to your computer and use it in GitHub Desktop.
Cleaned up version of DigiRGB script
#!/usr/bin/env python
#
# Written for PyUSB 1.0 (w/libusb 1.0.3)
#
# Original Author: follower@rancidbacon.com
# Heavily edited by bensonk42 -at- gmail
#
# Version: 2013-02-26
#
#
# Assumes 'DigiBlink.ino' is loaded on the DigiSpark and
# LEDs are present on pins 1, 2, 3
#
from arduino.usbdevice import ArduinoUsbDevice
import sys
import time
import usb # 1.0 not 0.4
import webcolors
if __name__ == '__main__':
theDevice = ArduinoUsbDevice(idVendor=0x16c0, idProduct=0x05df)
args = sys.argv[1:]
if len(args) == 1:
color_list = webcolors.name_to_rgb(sys.argv[1].lower())
color_list = list(color_list)
elif len(args) == 3:
color_list = map(int, args)
else:
sys.exit('usage: {0} <color>\n' +
'{0} <red> <green> <blue>'
.format(sys.argv[0]))
print color_list
theDevice.write(ord('s'))
for value in color_list:
theDevice.write(value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment