In this example we connect a WS2812B LED to an Adafruit Feather M0 running Circuitpython
In particular we are looking at several options which include LED rings like this
These come with various amounts of leds, you can also buy square boards like this
First lets look at some information about the WS2812B from the manufacturer
Description
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 24 bit 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 24 bit 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.
Features and Benefits
Intelligent reverse connect protection, the power supply reverse connection does not damage the IC.
The control circuit and the LED share the only power source.
Control circuit and RGB chip are integrated in a package of 5050 components, form a complete control of pixel point.
Built-in signal reshaping circuit, after wave reshaping to the next driver, ensure wave-form distortion not accumulate.
Built-in electric reset circuit and power lost reset circuit.
Each pixel of the three primary color can achieve 256 brightness display, completed 16777216 color full color display, and scan frequency not less than 400Hz/s.
Cascading port transmission signal by single line.
Any two point the distance more than 5m transmission signal without any increase circuit.
When the refresh rate is 30fps, cascade number are not less than 1024 points.
Send data at speeds of 800Kbps.
The color of the light were highly con
Parts Required
Name | Link |
Adafruit Feather M0 Express | Adafruit (PID 3403) Feather M0 Express – Designed for CircuitPython – ATSAMD21 Cortex M0 |
LED panel | WS2812B RGB LED panel with 16 LEDs |
WS2812B DIY LED Ring | WS2812B DIY LED Ring 8 12 16 24 35 45 LEDs |
Connecting cables | Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire |
Schematic/Connection
This is shows a 12 LED ring, all of these have the same connection. You just need to supply Vcc, GND and select the Data In pin.
These work fine with 3.3v
Code Example
I used Mu for development, you can use the neopixel library
The following is based on a library , I copied the neopixel.mpy to the lib folder on my Feather M0 Express – https://circuitpython.org/libraries
This was a 16 pixel led example, it will flash them all red, green then blue
[codesyntax lang=”python”]
import time import board import neopixel pixel_pin = board.D3 # The number of NeoPixels num_pixels = 16 ORDER = neopixel.GRB pixels = neopixel.NeoPixel( pixel_pin, num_pixels, brightness=0.01, auto_write=False, pixel_order=ORDER ) while True: pixels.fill((255, 0, 0)) pixels.show() time.sleep(1) pixels.fill((0, 255, 0)) pixels.show() time.sleep(1) pixels.fill((0, 0, 255)) pixels.show() time.sleep(1)
[/codesyntax]
This was a 7 pixel ring and we added another couple of colors to cycle through
[codesyntax lang=”python”]
import time import board import neopixel pixel_pin = board.D3 # The number of NeoPixels num_pixels = 7 ORDER = neopixel.GRB pixels = neopixel.NeoPixel( pixel_pin, num_pixels, brightness=0.01, auto_write=False, pixel_order=ORDER ) while True: pixels.fill((255, 0, 0)) pixels.show() time.sleep(1) pixels.fill((0, 255, 0)) pixels.show() time.sleep(1) pixels.fill((0, 0, 255)) pixels.show() time.sleep(1) pixels.fill((255, 0, 255)) pixels.show() time.sleep(1) pixels.fill((255, 255, 0)) pixels.show() time.sleep(1) pixels.fill((0, 255, 255)) pixels.show() time.sleep(1) pixels.fill((255, 255, 255)) pixels.show() time.sleep(1)
[/codesyntax]
Output