def connect(): port = None busses = serial.tools.list_ports.comports(); for bus in busses: for potential_port in bus: if "usbmodem" in potential_port: port = potential_port if not port: sys.exit("Could not locate a Blinkyboard.") print "Blinkyboard found at: %s" % port bb = Blinkyboard(port, 60, 'WS2811', gamma=[1,1,1]) bb.allOff() return bb
def connect(): port = None busses = serial.tools.list_ports.comports() for bus in busses: for potential_port in bus: if "usbmodem" in potential_port: port = potential_port if not port: sys.exit("Could not locate a Blinkyboard.") print "Blinkyboard found at: %s" % port bb = Blinkyboard(port, num_leds, 'LPD8806', gamma=[1, 1, 1]) bb.allOff() return bb
from Blinkyboard import Blinkyboard bb = Blinkyboard('/dev/cu.usbmodem1d11', 'WS2811') while True: for x in range(0, 60): bb.sendPixel(255, 255, 255) bb.show() for x in range(0, 60): bb.sendPixel(0, 0, 0) bb.show()
from Blinkyboard import Blinkyboard bb = Blinkyboard('/dev/cu.usbmodem1d11', 'WS2811') while True: for x in range(0, 60): bb.sendPixel(255,255,255) bb.show(); for x in range(0, 60): bb.sendPixel(0,0,0) bb.show()
import time import urllib from bs4 import BeautifulSoup #pip install beautifulsoup4 html5lib import Image #pip install PIL import base64 import tempfile import serial.tools.list_ports from Blinkyboard import Blinkyboard ports = serial.tools.list_ports.comports(); port = ports[0][0] bb = Blinkyboard(port, 60, 'WS2811', gamma=[2,1,4]) bb.allOff() #url = "http://www.aqicn.info/city/hongkong/" #url = "http://www.aqicn.info/city/shenzhen/" url = "http://www.aqicn.info/city/shenzhen/huaqiaocheng/" #url = "http://www.aqicn.info/city/beijing/" #url = "http://www.aqicn.info/city/shanghai/" #url = "http://www.aqicn.info/" positions = [243, 238, 233, 228, 223, 218, 213, 208, 203, 198, 193, 188, 183, 178, 173, 168, 163, 158, 153, 148, 143, 138, 133, 128, 123, 118, 113] try: while True: try: print "[%d] Scraping %s" % (time.time(), url) data = urllib.urlopen(url)