forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 3
Sample – NeoPixel
Takeo Takahashi edited this page Feb 17, 2022
·
3 revisions
from ws2812 import WS2812
chain = WS2812(spi_bus=1, led_count=12)
data = [
(255, 0, 0), # red
(0, 255, 0), # green
(0, 0, 255), # blue
(85, 85, 85), # white
(255, 0, 0), # red
(0, 255, 0), # green
(0, 0, 255), # blue
(85, 85, 85), # white
(255, 0, 0), # red
(0, 255, 0), # green
(0, 0, 255), # blue
(85, 85, 85), # white
]
chain.show(data)
-
You need to uplpad ws2812.py to the target board by ampy or copy & paste on REPL.
-
For EK-RA6M2, connect as followings:
NeoPixel-PIN EK-RA6M2-PIN DataIn P101 GND GND VCC 5V -
For RA4M1 Clicker, connect as followings:
NeoPixel-PIN RA4M1 Clicker-PIN DataIn P101 GND GND VCC 5V
- The original is https://github.com/JanBednarik/micropython-ws2812
One SPI clock is assigned to NeoPixel's low pulse, two clocks are assigned to high pulse, one bit is expressed by four clocks, and it is transmitted by DMA so that the waveform is not disturbed by software processing and interrupts. - In this implementation, DMA is not used, the encoding method is followed, 1 bit is expressed by 4 clocks, and 1 byte data is transferred by 32-bit transfer of SPI.
- Waveform when transmitting 1-byte data of 01010101