This tutorial shows you how to wire and program a WS2812B NeoPixel RGB LED ring with Raspberry Pi Pico using the Wokwi simulator. Create stunning light effects, animations, and color patterns!
What is a NeoPixel Ring?
A NeoPixel ring is a circular arrangement of addressable RGB LEDs (WS2812B). Each LED can display any color independently, making them perfect for animations, indicators, and decorative lighting projects.
Getting Started with Wokwi
Step 1: Open Wokwi and Create New Project
- Go to https://wokwi.com
- Click "New Project"
- Select "Raspberry Pi Pico" as your board
Step 2: Add the NeoPixel Ring Component
Add NeoPixel Ring:
- Click the blue "+" button
- Search for "NeoPixel" or "WS2812"
- Select "NeoPixel Ring" (typically 12, 16, or 24 LEDs)
- Click to add it to your workspace
- The default is usually a 12-LED ring
Configure Ring Size (Optional):
- Click on the NeoPixel ring
- In the properties panel, you can change:
- Number of pixels (12, 16, 24, etc.)
- Pin configuration
Step 3: Understanding NeoPixel Ring Pins
The NeoPixel ring has 3 or 4 connections:
- VCC/5V - Power supply (can use 3.3V or 5V)
- GND - Ground
- DIN/DATA - Data input signal
- DOUT - Data output (for chaining multiple rings - not needed for single ring)
Step 4: Wire the Circuit in Wokwi
Based on your diagram, make these connections:
Diagram.json:
{
"version": 1,
"author": "Uri Shaked",
"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" ] ]
]
}
Power Connection (Red Wire):
- Connect VCC on NeoPixel ring to VBUS (5V) or 3V3 on the Pico
- For best brightness, use VBUS (5V pin)
Ground Connection (Green/Black Wire):
- Connect GND on NeoPixel ring to GND on the Pico
- This completes the power circuit
Data Connection (Green Wire):
- Connect DIN (Data In) on NeoPixel ring to GP0 on the Pico
- You can use any GPIO pin, but GP0 is shown in your diagram
Wiring Steps:
- Click the VCC pin on the ring → drag to VBUS on Pico
- Click the GND pin on the ring → drag to GND on Pico
- Click the DIN pin on the ring → drag to GP0 on Pico
Step 5: Install NeoPixel Library Code
For Raspberry Pi Pico, you'll need to use the neopixel library. In Wokwi, create this code:
import time
from neopixel import Neopixel
pixels = Neopixel(17, 0, 6, "GRB")
colors = [
(0xb6, 0xe4, 0x30),
(0x42, 0xd1, 0xe0),
]
pixel_index = 0
color_index = 0
while True:
pixels.set_pixel(pixel_index, colors[color_index])
pixels.show()
#print(pixel_index, colors[color_index])
pixel_index += 1
if pixel_index == 16:
pixel_index = 0
color_index = (color_index + 1) % 2
time.sleep(0.1)

Comments
Post a Comment