#! /usr/bin/python # print "Content-Type: text/html\n" from pyglow import PyGlow from time import sleep from datetime import datetime import random pyglow = PyGlow() pyglow.all(0) random.seed(datetime.now().time()) randomLightsInt = random.randint(0,262143) randomLightBits = "{0:b}".format(randomLightsInt) i = 1 leds = [] for c in randomLightBits: if (int(c)*i>0): leds.append(i) i=i+1 pyglow.set_leds(leds, 50) pyglow.update_leds()
from time import sleep pyglow = PyGlow() try: while True: ## choose a set of leds leds = [1,3,5,11,13,15] ## save them with the brightness you want pyglow.set_leds(leds,50) ## wait to demonstrate... sleep(3) ## light up the leds! pyglow.update_leds() sleep(3) ## now we want to shut down the first set pyglow.set_leds(leds,0) ## ...build a newer, brighter set leds = [2,4,9] pyglow.set_leds(leds,150) ## and update the leds! pyglow.update_leds() except KeyboardInterrupt: pyglow.all(0)