Nucleo-MicroPythonにNeoPixelを接続する
2020/3/9
Nucleo MicroPython NeoPixel demo
Nucleo MicroPython NeoPixel demo
概要
Nucleo-MicroPythonボードにNeoPixelを接続する。今回、使用するモジュールは ハードウェアSPIを利用したもので、pyboard/Nucleo用であるが、 ハードウェアSPIを持ったボードであれば、該当モジュールの多少の変更で適用可能と思われる。
関連モジュールのインストール
以下の手順でインストールする:
git clone https://github.com/JanBednarik/micropython-ws2812.git
cd micropython-ws2812
ampy put ws2812.py
デモ・スクリプト
Nucleo-MicroPythonボードに以下のようにneopixelを接続する。
接続表:
neopixel | Nucleo/Arduino-Pin |
---|---|
DIN | D4 |
VCC | 3.3V or 5V |
GND | GND |
sample1:
# connect the following pin to DIN of nexpixels
# D11 (if spi_bus=1) or D4 (if spi_bus=3)
from ws2812 import WS2812
chain = WS2812(spi_bus=3, led_count=4)
data = [
(255, 0, 0), # red
(0, 255, 0), # greenp
(0, 0, 255), # blue
(85, 85, 85), # white
]
chain.show(data)
sample2:
from time import sleep
import math
from ws2812 import WS2812
ring = WS2812(spi_bus=3, led_count=16, intensity=0.1)
def data_generator(led_count):
data = [(0, 0, 0) for i in range(led_count)]
step = 0
while True:
red = int((1 + math.sin(step * 0.1324)) * 127)
green = int((1 + math.sin(step * 0.1654)) * 127)
blue = int((1 + math.sin(step * 0.1)) * 127)
data[step % led_count] = (red, green, blue)
yield data
step += 1
for data in data_generator(ring.led_count):
ring.show(data)
sleep(0.01)
参照URL
MicroPython WS2812 driver
circuitpython-neopixels-using-spi
M5Stack用NeoPixel互換 LEDテープ 10 cm
NUCLEO F446RE MicroPython インストール方法
以上
| 固定リンク
「linux」カテゴリの記事
- platfomioを使ってnaitive(linux/windows)のプログラムをビルドする方法(2021.03.10)
- micro:bit Yotta開発ツール(linux版)(2021.01.09)
- PlatformIOをRaspberryPi4で動かしてみる(実験)(2020.10.20)
- headless RaspberryPiインストール方法(v2)(2020.10.20)
- wio-terminalのファームウェア・アップデートについて(linux版)(2020.10.15)
「MicroPython」カテゴリの記事
- microbit-v2にMicropythonをインストールする(2021.05.06)
- PicoボードのMicroPythonをVS_CodeのextensionのPico-Goでプログラミングする(2021.02.10)
- MicroPython/CircuitPython Performance Test(2021.02.07)
- PicoボードにMicropython/CircuitPythonをインストールする(2021.02.03)
- MicroPython(F767ZI) Network Samples(2021.01.03)
「Nucleo」カテゴリの記事
- MicroPython/CircuitPython Performance Test(2021.02.07)
- MicroPython(F767ZI) Network Samples(2021.01.03)
- MicroPython(F767ZI)でStartwars(AsciiArt)を動かす(2020.12.29)
- NUCLEO-F767ZIにMicropythonをインストールする(v2)(2020.05.22)
- Nucleo-F303K8でADCの値をLCD(AQM0802)(i2c)に表示する(Arduino版)(2020.05.16)
コメント