Ithamar_code/documentation/source/J1P2/Pico/discolight_sl.py

64 lines
1.7 KiB
Python
Raw Permalink Normal View History

2023-08-25 17:35:45 +00:00
from neopixel import Neopixel
import random
import time
def DiscoLed():
pixels = Neopixel(30, 0, 16, "GRB")
# pixels.fill((255, 255, 255))
# pixels.brightness(50)
# pixels.fill(orange)
while True:
for i in range(30):
pixels.set_pixel(i, (random.randint(0,255),random.randint(0,255),random.randint(0,255)))
pixels.brightness(random.randint(0,50))
pixels.show()
def police():
pixels = Neopixel(30, 0, 16, "GRB")
red = (255, 0, 0)
blue = (9, 0, 255)
null = (0, 0, 0)
redls = []
bluels = []
knipper_aan = True
while True:
if knipper_aan:
for i in range(30):
if i % 2 == 0:
redls.append(i)
pixels.set_pixel(i, red)
# time.sleep(0.1)
pixels.show()
knipper_aan = False
time.sleep(1)
pixels.fill(null)
time.sleep(1)
if knipper_aan == False:
for u in range(30):
if u % 2 != 0:
bluels.append(u)
pixels.set_pixel(u, blue)
# time.sleep(0.1)
pixels.show()
knipper_aan = True
pixels.fill(null)
time.sleep(2)
# else:
# knipper_aan = True
# for u in range(30):
# if u % 2 == -1:
# pixels.set_pixel(u, blue)
# time.sleep(1)
pixels.brightness(30)
pixels.show()
def shutoff():
pixels = Neopixel(30, 0, 16, "GRB")
pixels.fill((0, 0, 0))
pixels.show()