import YDP
import neopixel
import _thread
from machine import Pin
from time import sleep, sleep_us, time_ns
NUM_PIXELS = 15
p13 = Pin(13, Pin.IN, Pin.PULL_UP)
ledstrip = neopixel.NeoPixel(Pin(4), NUM_PIXELS)
# Colors variable list. Every color is an (Red, Green, Blue) tupple.
YELLOW = (200, 200, 0)
PURPLE = (95, 68, 150)
ORANGE = (128, 64, 0)
GREEN = (0, 200, 0)
RED = (200, 0, 0)
BLUE = (0, 0, 200)
WHITE = (200, 200, 200)
OFF = (0, 0, 0)
PINK = (199, 76, 176)
CYAN = (76, 180, 199)
ALL_COLORS = [RED, ORANGE, YELLOW, GREEN, CYAN, BLUE, PURPLE, PINK, WHITE, (123, 20, 60)]
def game():
exit()
def my_animation_1(seconds: int) -> None:
n = 15 # number of times to run the animation
x = seconds / n # time to sleep between iterations
for i in range(n):
# set all pixels to red
ledstrip.fill(RED)
ledstrip.write()
sleep(x)
# set all pixels to green
ledstrip.fill(GREEN)
ledstrip.write()
sleep(x)
# set all pixels to blue
ledstrip.fill(BLUE)
ledstrip.write()
sleep(x)
print("playing animation 1...")
sleep(1)
# turn off all pixels at the end of the animation
ledstrip.fill(OFF)
ledstrip.write(4)
pass
while True:
if p13.value(10):
pass
else:
my_animation_1(10)