micropython 範例三
點亮擴充板上內建的 WS2812 全彩 LED,R->G->B 輪流點亮
注意事項 : 由於 LED 的亮度很高,使用時眼睛請勿直視
# 範例三:
# 讓擴充板內建的全彩 LED (WS2812) R->G->B 循環亮五次
# 使用 GPIO2 / GPIO12
# FB : https://www.facebook.com/mason.chen.1420
from machine import Pin
from neopixel import NeoPixel
from time import sleep
np = NeoPixel(Pin(17, Pin.OUT), 1); np.bright = 50
for count in range(5):
np[0] = (int(255 * np.bright / 100), int(0 * np.bright / 100), int(0 * np.bright / 100))
np.write()
sleep(1)
np[0] = (int(51 * np.bright / 100), int(255 * np.bright / 100), int(51 * np.bright / 100))
np.write()
sleep(1)
np[0] = (int(51 * np.bright / 100), int(51 * np.bright / 100), int(255 * np.bright / 100))
np.write()
sleep(1)
for i in range(np.n): np[i] = (0, 0, 0)
np.write()