Raspberry Pi Pico WS2812B NeoPixel Ring Tutorial (Wokwi Simulator)

NeoPixel RGB LED Ring with Raspberry Pi Pico – Wokwi Tutorial | MakeMindz
🌈 Intermediate LED Project

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.

🍓 Pi Pico 💡 WS2812B Ring (16 LEDs) 🐍 MicroPython 🎨 16M+ Colors 🧪 Wokwi

🚀 See the animation live — simulate this NeoPixel project free in your browser

▶ Open Free Simulation
💡

What is a NeoPixel Ring?

16LEDs in Ring
1Data Pin (GP6)
16M+Color Combos
100msAnimation Step

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.

🎯
Individually Addressable
Each LED has its own memory. You can set any LED to any color without affecting others.
🔗
Single Data Wire
Just GP6 from the Pico controls all 16 LEDs via a chained data protocol — no extra pins needed.
🎨
24-bit Color
8 bits each for Red, Green, Blue = over 16 million possible color combinations per LED.
🔁
Chainable
Use DOUT to chain multiple rings together, all still controlled from a single Pico GPIO pin.
🔧

Hardware & Pin Overview

🍓
Raspberry Pi Pico
Standard or Pico W
💡
WS2812B NeoPixel Ring
12, 16, or 24 LED options
🧪
Wokwi Simulator
Free online — no hardware needed
NeoPixel Ring Pin Functions
VCC Power — 3.3V or 5V (VBUS)
GND Ground — Pico GND pin
DIN Data In — GP6 on Pico
DOUT Data Out — chain to next ring (optional)
💡 3V3 vs VBUS — Which to Use?

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 PinRaspberry Pi Pico PinWire ColorNotes
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
⚡ Power Tip for Real Hardware

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.

1
Pico sends the full data stream
The Pico sends 16 × 24 = 384 bits in sequence down the single DIN wire — all LED colors in one burst.
2
LED 1 reads its 24 bits
The first LED absorbs the first 24 bits (8 green + 8 red + 8 blue) and stores them as its color.
3
Remaining data cascades forward
The remaining bits pass through DOUT to LED 2, which reads its 24 bits. This repeats until all 16 LEDs have their color data.
4
pixels.show() latches all colors
Calling pixels.show() in MicroPython sends the full data stream. Until then, colors are buffered in RAM — LEDs don't update mid-sequence.
Color Data Format (GRB byte order for WS2812B)
Yellow-Green
(0xb6, 0xe4, 0x30)
Cyan-Blue
(0x42, 0xd1, 0xe0)

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

1
Open Wokwi & Start a Pico Project
Go to wokwi.com, click New Project, and select Raspberry Pi Pico. Or click the Free Simulation button at the top of this page to open the pre-built NeoPixel ring project instantly.
💡 The free simulation link launches the exact finished circuit — no setup required.
2
Add the NeoPixel Ring Component
In Wokwi, click the blue "+" Add Part button. Search for NeoPixel or WS2812 and select NeoPixel Ring. In the properties panel, set pixels: 16 (or 12/24 for other ring sizes). The ring appears on the canvas.
ℹ️ If using the diagram.json from Step 6, this is done for you automatically.
3
Paste the diagram.json
Click the 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.
4
Add the NeoPixel Library
In Wokwi, click the Libraries tab (book icon) and add neopixel. This imports the 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.
💡 In Wokwi the library is built-in for Pico projects — the from neopixel import Neopixel import works out of the box.
5
Paste the MicroPython Code
Open the 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.
ℹ️ The code uses 17 in the Neopixel constructor — this accounts for 16 ring LEDs plus 1 internal LED on some Pico variants.
6
Run the Simulation & Watch the Animation
Click the green ▶ Play button. LEDs light one at a time in a rotating pattern. After a full revolution (16 steps), the color switches from yellow-green to cyan-blue. The cycle repeats continuously at 100ms per step.
7
Customize Colors and Speed
Edit the 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.
💡 Try (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.

📄 diagram.json
{
  "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"] ]
  ]
}
📌 Customizing the Ring Size
  • 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.

🐍 main.py (MicroPython)
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
📌 Key Code Parameters
  • 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 conversion
  • pixels.set_pixel(index, color) — sets one LED; changes are buffered until show()
  • pixels.show() — must be called after setting pixels to actually update the ring
  • color_index % 2 — cycles between 0 and 1, alternating the two colors
  • time.sleep(0.1) — 100ms step delay; reduce to 0.05 for faster animation

Effects You Can Build

🌈
Rainbow Cycle
🔄
Rotating Color Wheel
💫
Breathing LED Effect
🎵
Music Visualizer
🔔
Notification Ring
Circular Progress Bar
Real-World Applications
🏠
Smart Home Lighting
🤖
Robotics Status Ring
📊
IoT Dashboards
👕
Wearable Electronics
🎨
Decorative Art
🎮
Gaming UI Lighting
🚦
Interactive Feedback
What You Will Learn
WS2812B NeoPixel protocol and GRB byte order
MicroPython neopixel library usage
Single-wire LED control from one GPIO pin
Frame-buffered display — set then show()
Animation loops and timing with time.sleep()
Hex color codes and RGB color mixing

🌈 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
✓ Pre-wired circuit ✓ Live color animation ✓ Edit code in browser ✓ Completely free

Comments

try for free