In this example we look at some WS2812B RGB LEDs example in Micropython for an ESP8266. Once again we use uPyCraft and this time I use a WS2812b module as I couldn't get the Wemos sensor example
WS2812B is a intelligent control LED light source that the control circuit and RGB chip are integrated in a package of 5050 components. It internal include intelligent digital port data latch and signal reshaping amplification drive circuit. Also include a precision internal oscillator and a 12V voltage programmable constant current control part, effectively ensuring the pixel point light color height consistent.
The data transfer protocol use single NZR communication mode. After the pixel power-on reset, the DIN port receive data from controller, the first pixel collect initial 24bit data then sent to the internal data latch, the other data which reshaping by the internal signal reshaping amplification circuit sent to the next cascade pixel through the DO port. After transmission for each pixel,the signal to reduce 24bit. pixel adopt auto reshaping transmit technology, making the pixel cascade number is not limited the signal transmission, only depend on the speed of signal transmission.
LED with low driving voltage, environmental protection and energy saving, high brightness, scattering angle is large, good consistency, low power, long life and other advantages. The control chip integrated in LED above becoming more simple circuit, small volume, convenient installation
Requirements
Lets take a look a the shields and boards that are required for this example
Parts List
I connect the MH-ET LIVE ESP32 MINI KIT to the dual base and then connect the WS2812 breakout to this
Name | Link |
MH-ET LIVE ESP32 MINI KIT | MH-ET LIVE ESP32 MINI KIT WiFi+Bluetooth Internet of Things development board based ESP8266 Fully functional D1 MINI Upgraded |
Wemos Base | Tripler Base V1.0.0 Shield for WeMos D1 Mini |
WS2812 RGB LED Breakout Module | New WS2812 RGB LED Breakout Module for Arduino |
Connection
WS2812 breakout | MH-ET LIVE ESP32 MINI KIT |
5v | 3v3
|
DI | IO16 |
Gnd | Gnd |
Code
Example 1
[codesyntax lang=”python”]
from machine import Pin import neopixel pixels = neopixel.NeoPixel(Pin(16, Pin.OUT), 1) pixels[0] = (0xff, 0x00, 0x00) pixels.write()
[/codesyntax]
Example 2
[codesyntax lang=”python”]
from machine import Pin import neopixel import time pixels = neopixel.NeoPixel(Pin(16, Pin.OUT), 1) while True: pixels[0] = (0xff, 0x00, 0x00) pixels.write() time.sleep(1) pixels[0] = (0x00, 0xff, 0x00) pixels.write() time.sleep(1) pixels[0] = (0x00, 0x00, 0xff) pixels.write() time.sleep(1)
[/codesyntax]
Example 3
[codesyntax lang=”python”]
from machine import Pin import neopixel import time pixels = neopixel.NeoPixel(Pin(16, Pin.OUT), 1) while True: pixels[0] = (0xff, 0x00, 0x00) pixels.write() time.sleep(1) pixels[0] = (0x00, 0xff, 0x00) pixels.write() time.sleep(1) pixels[0] = (0x00, 0x00, 0xff) pixels.write() time.sleep(1) pixels[0] = (0xff, 0xff, 0x00) pixels.write() time.sleep(1) pixels[0] = (0x00, 0xff, 0xff) pixels.write() time.sleep(1) pixels[0] = (0xff, 0x00, 0xff) pixels.write() time.sleep(1) pixels[0] = (0xff, 0xff, 0xff) pixels.write() time.sleep(1)
[/codesyntax]
Links