Created
October 13, 2016 18:20
-
-
Save dglaude/9094d66a06114727672395fc636525d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f=open("mote.py","w") | |
f.write(''' | |
from machine import Pin | |
from apa102 import APA102 | |
import colorsys | |
import time | |
def main(): | |
clock = Pin(14, Pin.OUT) | |
data = Pin(13, Pin.OUT) | |
mote = APA102(clock, data, 16) | |
spacing = 360.0 / 16.0 | |
hue = 0 | |
while True: | |
hue = int(time.ticks_ms() / 10) % 360 | |
for x in range(16): | |
offset = x * spacing | |
h = ((hue + offset) % 360) / 360.0 | |
r, g, b = [int(c*255) for c in colorsys.hsv_to_rgb(h, 1.0, 1.0)] | |
mote[x] = (r, g, b, 8) | |
mote.write() | |
time.sleep_ms(10) | |
''') | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment