Here\'s my iteration:
#!/usr/bin/python
#
# Set Arduino IDE to use \"Digispark (Tiny Core)\",
# load DigiBlink.ino sketch onto the Digispark, connect
# Pin 0 (=ATtiny 5th pin) -> red RGB LED anode
# Pin 1 (=ATtiny 6th pin) -> green RGB LED anode
# Pin 2 (=ATtiny 7th pin) -> blue RGB LED anode
# and the RGB LED cathode via a suitable resistor to GND
# then run this script with a web color name, e.g.,
# sudo ./DigiRGB.py yellow
# or with some RGB color, e.g.,
# sudo ./DigiRGB.py 0 0 255
#
import sys, time
import usb # PyUSB 1.0, to be bundled
import webcolors # to be bundled
from arduino.usbdevice import ArduinoUsbDevice # to be bundled
if __name__ == \"__main__\":
theDevice = ArduinoUsbDevice(idVendor=0x16c0, idProduct=0x05df)
print \"Found: 0x%04x 0x%04x %s %s\" % (theDevice.idVendor,
theDevice.idProduct,
theDevice.productName,
theDevice.manufacturer)
if len(sys.argv)==1:
color_list = [255,255,255]
elif (len(sys.argv)>1 and len(sys.argv)<3):
color_list = webcolors.name_to_rgb(sys.argv[1].lower())
color_list = list(color_list)
else:
color_list = sys.argv[1:4]
print(\"Send initialization to USB\")
theDevice.write(ord(\"s\"))
print(\"Send colors to USB\")
for color in color_list:
if color == 0:
theDevice.write(0)
else:
theDevice.write(int(color))