micro_mpc_kmk/led_panel_blink.py

29 lines
813 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from machine import Pin
import neopixel
import time
import random
# Настройки: 8 LED, подключено к GP6
num_leds = 8
pin = 6 # 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)