29 lines
813 B
Python
29 lines
813 B
Python
from machine import Pin
|
|
import neopixel
|
|
import time
|
|
import random
|
|
|
|
# Настройки: 8 LED, подключено к GP6
|
|
num_leds = 8
|
|
pin = 0 # GP6
|
|
|
|
np = neopixel.NeoPixel(Pin(pin), num_leds)
|
|
|
|
red = (255, 0, 0) # Красный (R, G, B)
|
|
green = (0, 255, 0) # Зеленый
|
|
blue = (0, 0, 255) # Синий
|
|
orange = (255, 165, 0) # Оранжевый
|
|
moon_white = (224, 224, 192) # Лунный белый
|
|
off = (0, 0, 0) # Выключено
|
|
|
|
while True:
|
|
np.fill(red) # Все LED красные
|
|
colors = [red, green, blue, orange, moon_white]
|
|
for i in range(num_leds):
|
|
np[i] = random.choice(colors)
|
|
np.write() # Обновить
|
|
time.sleep(0.5) # Пауза 0.5 сек
|
|
|
|
np.fill(off) # Все выключить
|
|
np.write()
|
|
time.sleep(0.5) |