Skip to content

Instantly share code, notes, and snippets.

@noahwilliamsson
Created December 18, 2018 20:07
Show Gist options
  • Save noahwilliamsson/31550319641f61dfb5637138aad862f2 to your computer and use it in GitHub Desktop.
Save noahwilliamsson/31550319641f61dfb5637138aad862f2 to your computer and use it in GitHub Desktop.
Pycom LoPy (ESP32) Micropython RMT example for WS2812
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,5,4,9,8,5,8,5,8,5],
[4,9,4,9,4,9,8,5,8,5,4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,8,5,4,9,8,5,8,5],
[8,5,8,5,8,5,4,9,8,5,8,5,4,9,4,9],
[8,5,8,5,8,5,4,9,8,5,8,5,4,9,8,5],
[8,5,8,5,8,5,4,9,8,5,8,5,8,5,4,9],
[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,4,9,4,9],
[8,5,8,5,8,5,8,5,4,9,4,9,4,9,8,5],
[8,5,8,5,8,5,8,5,4,9,4,9,8,5,4,9],
[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,4,9,4,9],
[8,5,8,5,8,5,8,5,4,9,8,5,4,9,8,5],
[8,5,8,5,8,5,8,5,4,9,8,5,8,5,4,9],
[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,4,9],
[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,4,9],
[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