Created
December 18, 2018 20:07
-
-
Save noahwilliamsson/31550319641f61dfb5637138aad862f2 to your computer and use it in GitHub Desktop.
Pycom LoPy (ESP32) Micropython RMT example for WS2812
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brightness_lut = [ | |
[4,9,4,9,4,9,4,9,4,9,4,9,4,9,4,9], | |
[4,9,4,9,4,9,4,9,4,9,4,9,4,9,8,5], | |
[4,9,4,9,4,9,4,9,4,9,4,9,8,5,4,9], | |
[4,9,4,9,4,9,4,9,4,9,4,9,8,5,8,5], | |
[4,9,4,9,4,9,4,9,4,9,8,5,4,9,4,9], | |
[4,9,4,9,4,9,4,9,4,9,8,5,4,9,8,5], | |
[4,9,4,9,4,9,4,9,4,9,8,5,8,5,4,9], | |
[4,9,4,9,4,9,4,9,4,9,8,5,8,5,8,5], | |
[4,9,4,9,4,9,4,9,8,5,4,9,4,9,4,9], | |
[4,9,4,9,4,9,4,9,8,5,4,9,4,9,8,5], | |
[4,9,4,9,4,9,4,9,8,5,4,9,8,5,4,9], | |
[4,9,4,9,4,9,4,9,8,5,4,9,8,5,8,5], | |
[4,9,4,9,4,9,4,9,8,5,8,5,4,9,4,9], | |
[4,9,4,9,4,9,4,9,8,5,8,5,4,9,8,5], | |
[4,9,4,9,4,9,4,9,8,5,8,5,8,5,4,9], | |
[4,9,4,9,4,9,4,9,8,5,8,5,8,5,8,5], | |
[4,9,4,9,4,9,8,5,4,9,4,9,4,9,4,9], | |
[4,9,4,9,4,9,8,5,4,9,4,9,4,9,8,5], | |
[4,9,4,9,4,9,8,5,4,9,4,9,8,5,4,9], | |
[4,9,4,9,4,9,8,5,4,9,4,9,8,5,8,5], | |
[4,9,4,9,4,9,8,5,4,9,8,5,4,9,4,9], | |
[4,9,4,9,4,9,8,5,4,9,8,5,4,9,8,5], | |
[4,9,4,9,4,9,8,5,4,9,8,5,8,5,4,9], | |
[4,9,4,9,4,9,8,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
[8,5,8,5,8,5,8,5,8,5,4,9,8,5,8,5], | |
[8,5,8,5,8,5,8,5,8,5,8,5,4,9,4,9], | |
[8,5,8,5,8,5,8,5,8,5,8,5,4,9,8,5], | |
[8,5,8,5,8,5,8,5,8,5,8,5,8,5,4,9], | |
[8,5,8,5,8,5,8,5,8,5,8,5,8,5,8,5], | |
] | |
black = brightness_lut[0] | |
light = brightness_lut[32] | |
from machine import RMT | |
# P22 is the fifth pin from the top-right | |
rmt = RMT(channel=3, gpio='P22', tx_idle_level=0) | |
buf = bytearray() | |
for i in range(4): | |
buf.extend(light) # green | |
buf.extend(light) # red | |
buf.extend(light) # blue | |
out_buf = tuple(buf) # RMT wants immutable tuples | |
rmt.pulses_send(out_buf, start_level=RMT.HIGH) | |
rmt.deinit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment