NeoPixel RGB LED Ring with Raspberry Pi Pico
Wire a WS2812B NeoPixel ring to your Raspberry Pi Pico and create stunning circular light animations using MicroPython. Just one GPIO pin controls all 16 LEDs. Simulate free in Wokwi.
🚀 See the animation live — simulate this NeoPixel project free in your browser
▶ Open Free SimulationWhat is a NeoPixel Ring?
A NeoPixel ring is a circular arrangement of individually addressable WS2812B RGB LEDs. Unlike traditional LEDs that all turn on together, each NeoPixel can display any color independently. Best of all, the entire ring is controlled through a single data wire — making wiring beautifully simple.
Hardware & Pin Overview
The Wokwi diagram connects VCC to 3V3 (3.3V) which works fine for simulation. On real hardware, connect to VBUS (5V) for maximum brightness, especially with 16+ LEDs. The WS2812B is rated for 5V but functions at 3.3V with slightly reduced brightness.
Wiring Connections
Only three wires needed — power, ground, and data. The simplest wiring of any multi-LED project.
| NeoPixel Ring Pin | Raspberry Pi Pico Pin | Wire Color | Notes |
|---|---|---|---|
| VCC | 3V3 (or VBUS for 5V) | Red | Use VBUS for full brightness |
| GND | GND.3 | Black | Any GND pin on Pico |
| DIN | GP6 | Green | Any GPIO pin works — GP6 used here |
| DOUT | Not connected | — | Only needed when chaining rings |
At full white (R:255, G:255, B:255), each WS2812B LED draws ~60mA. A 16-LED ring at full brightness draws up to 960mA. The Pico's 3V3 regulator is only rated for 300mA total. For high-brightness projects, power the ring directly from a 5V supply and share GND with the Pico.
How NeoPixels Work
NeoPixels use a single-wire digital communication protocol. The Pico sends a stream of color data, and the ring's LEDs each read their 24 bits, then pass the rest down the chain.
The Pico sends 16 × 24 = 384 bits in sequence down the single DIN wire — all LED colors in one burst.
The first LED absorbs the first 24 bits (8 green + 8 red + 8 blue) and stores them as its color.
The remaining bits pass through DOUT to LED 2, which reads its 24 bits. This repeats until all 16 LEDs have their color data.
Calling
pixels.show() in MicroPython sends the full data stream. Until then, colors are buffered in RAM — LEDs don't update mid-sequence.Note: WS2812B uses GRB order (Green first, then Red, then Blue) — not the usual RGB. The Neopixel library handles this automatically when you pass "GRB" as the color order parameter.
Step-by-Step Build Guide
diagram.json tab and replace all content with the JSON from Step 6 below. This sets up the Pico, places the 16-LED ring, and connects VCC → 3V3, GND → GND.3, and DIN → GP6 automatically.Neopixel class needed by the MicroPython code. On a real Pico, download neopixel.py from the MicroPython extras repository and copy it to the board using Thonny.from neopixel import Neopixel import works out of the box.main.py tab in Wokwi and replace all content with the code from Step 7 below. Key parameters to note: 17 pixels, state machine 0, GP6, and "GRB" color order.colors list to add your own hex color tuples. Change time.sleep(0.1) to adjust animation speed — lower value = faster. Experiment with filling multiple LEDs at once or creating gradient effects by calculating intermediate colors.(255, 0, 0) for red, (0, 255, 0) for green, (0, 0, 255) for blue — remember GRB order doesn't matter here as the library handles it.Wokwi diagram.json
The simplest diagram.json of any MakeMindz tutorial — just the Pico, the 16-LED ring, and 3 connections.
{
"version": 1,
"author": "MakeMindz",
"editor": "wokwi",
"parts": [
{
"type": "wokwi-pi-pico",
"id": "pico",
"top": 80.37,
"left": 2.96,
"attrs": { "env": "micropython-20210902-v1.17" }
},
{
"type": "wokwi-led-ring",
"id": "ring1",
"top": 3.2,
"left": -177.15,
"attrs": { "pixels": "16" }
}
],
"connections": [
[ "pico:GP6", "ring1:DIN", "green", ["h0"] ],
[ "ring1:VCC", "pico:3V3", "red", ["v128.24","h238.19","v-147.43"] ],
[ "ring1:GND", "pico:GND.3", "black", ["v0"] ]
]
}
- Change
"pixels": "16"to"12"or"24"for different ring sizes - Update the
Neopixel(17, 0, 6, "GRB")constructor in code to match (e.g. 13 for a 12-LED ring) - Change
if pixel_index == 16:to match your pixel count - To use VBUS (5V) instead of 3V3, change
"pico:3V3"→"pico:VBUS"in connections - Data pin is GP6 by default — change
"pico:GP6"to use any other GPIO pin
MicroPython Code (main.py)
Paste into the main.py tab in Wokwi. On real hardware, save as main.py on the Pico using Thonny IDE.
import time from neopixel import Neopixel # Initialize 16 NeoPixels on GP6 # Neopixel(num_leds, state_machine, pin, color_format) pixels = Neopixel(17, 0, 6, "GRB") # Define two colors to alternate between # Format: (R, G, B) — library converts to GRB internally colors = [ (0xb6, 0xe4, 0x30), # Yellow-green (0x42, 0xd1, 0xe0), # Cyan-blue ] pixel_index = 0 # Which LED is currently lit color_index = 0 # Which color from the list to use while True: # Light the current LED with the current color pixels.set_pixel(pixel_index, colors[color_index]) pixels.show() # Send data to the ring — LEDs update now # Uncomment to debug in serial monitor: # print(pixel_index, colors[color_index]) pixel_index += 1 # After completing a full revolution, swap colors if pixel_index == 16: pixel_index = 0 color_index = (color_index + 1) % 2 # Toggle 0 ↔ 1 time.sleep(0.1) # 100ms per LED step → ~1.6s per full rotation
Neopixel(17, 0, 6, "GRB")— 17 pixels, state machine 0, GPIO pin 6, GRB color order"GRB"— WS2812B uses Green-Red-Blue byte order; the library handles the conversionpixels.set_pixel(index, color)— sets one LED; changes are buffered untilshow()pixels.show()— must be called after setting pixels to actually update the ringcolor_index % 2— cycles between 0 and 1, alternating the two colorstime.sleep(0.1)— 100ms step delay; reduce to 0.05 for faster animation
Effects You Can Build
🌈 Watch the Animation Live
The full circuit is pre-built. Click play and watch the NeoPixel ring light up and alternate colors in real time — no hardware required.
▶ Open Free Simulation
Comments
Post a Comment