print("""Rainbow Press Ctrl+C to clear and exit. """) mote.configure_channel(1, 16, False) mote.configure_channel(2, 16, False) mote.configure_channel(3, 16, False) mote.configure_channel(4, 16, False) h = 1 try: while True: for channel in range(1, 5): pixel_count = mote.get_pixel_count(channel) for pixel in range(pixel_count): hue = (h + ((channel - 1) * pixel_count * 5) + (pixel * 5)) % 360 r, g, b = [ int(c * 255) for c in hsv_to_rgb(hue / 360.0, 1.0, 1.0) ] mote.set_pixel(channel, pixel, r, g, b) mote.show() time.sleep(0.05) except KeyboardInterrupt: mote.clear() mote.show()
motephat.configure_channel(2, num_pixels, False) motephat.configure_channel(3, num_pixels, False) motephat.configure_channel(4, num_pixels, False) try: while True: r = requests.get('http://api.thingspeak.com/channels/1417/feed.json') j = r.json() f = j['feeds'][-8:] f = [element for index, element in enumerate(f) if index % 2 == 0] print(f) channel = 1 for col in f: col = col['field2'] r, g, b = tuple(ord(c) for c in col[1:].lower().decode('hex')) for pixel in range(motephat.get_pixel_count(channel)): motephat.set_pixel(channel, pixel, r, g, b) channel += 1 motephat.show() time.sleep(5) except KeyboardInterrupt: motephat.clear() motephat.show() time.sleep(0.1)