Подключение ws2812B-16 к Raspberry PI 3
Схема подключения:
Установим необходимые библиотеки:
1 |
pip3 install rpi_ws281x adafruit-circuitpython-neopixel |
Помигаем светодиодами:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import board import neopixel import time import random pixels = neopixel.NeoPixel(board.D18, 17) time.sleep(5) for n in range(16): pixels[n] = (255, 0, 0) time.sleep(0.1) pixels[n] = (255, 255, 0) time.sleep(0.1) pixels[n] = (255, 255, 255) for n in range(16): pixels[n] = (0, 0, 0) for n in range(10000): to=random.randint(0,16) pixels[to]=(random.randint(1,55), random.randint(1,55), random.randint(1,55)) to=random.randint(0,16) pixels[to]=(0,0,0) |