-
-
Save lizzybrooks/350f56e385e4a160ccddb4d3df5a2a9a to your computer and use it in GitHub Desktop.
Organic Light pattern with switch (doesn't work)
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
import time | |
import board | |
import neopixel | |
from digitalio import DigitalInOut, Direction, Pull | |
pixel_pin = board.D2 | |
num_pixels = 12 | |
switch = DigitalInOut(board.D3) | |
switch.direction = Direction.INPUT | |
switch.pull = Pull.UP | |
pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=0.5, auto_write=False) | |
ROBIN = (222,35,5) | |
ROBINDIM = (111,18,3) | |
ROBINDIMMER = (56,12,2) | |
ROBINDIMMEST = (28,6,1) | |
OFF = (0,0,0) | |
while True: | |
print(switch.value) | |
if (switch.value==True): | |
for i in range(0,12,1): | |
pixels[i]=OFF | |
pixels.show() | |
time.sleep(0.1) | |
pixels[i-1]=ROBINDIMMEST | |
pixels.show() | |
time.sleep(0.1) | |
if (switch.value==False): | |
break | |
print("broke loop") | |
pixels[i-2]=ROBINDIMMER | |
pixels.show() | |
time.sleep(0.1) | |
pixels[i-3]=ROBINDIM | |
pixels.show() | |
time.sleep(0.1) | |
pixels[i-4]=ROBIN | |
pixels.show() | |
time.sleep(0.1) | |
else: | |
pixels.fill(OFF) | |
pixels.show() | |
time.sleep(1) # debounce delay |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment