Raspberry Pi Pico NeoPixel Ring: Wiring, Code and Simulator
To build this Raspberry Pi Pico NeoPixel Ring project you need a Raspberry Pi Pico and a NeoPixel ring. The neopixel module drives a 12-pixel ring on GP16 with the RP2040 PIO. Make the 3 connections in the wiring table, upload the MicroPython code, and the bit timing comes from a PIO state machine, not the CPU: the Pico special trick.
Open this circuit in the free Raspberry Pi Pico simulator
Parts list
| Qty | Part | What it does |
|---|---|---|
| 1 | Raspberry Pi Pico | the microcontroller board |
| 1 | NeoPixel ring | A ring of WS2812 pixels. DIN from a pin, VCC to 5V, GND to GND. |
Wiring
| # | From | To |
|---|---|---|
| 1 | Raspberry Pi Pico GP16 | NeoPixel ring DIN |
| 2 | Raspberry Pi Pico VBUS | NeoPixel ring VCC |
| 3 | Raspberry Pi Pico GND | NeoPixel ring GND |
Step by step
- Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Raspberry Pi Pico. No install or account is needed.
- Add the parts. Add a NeoPixel ring from the parts palette.
- Wire 1. Connect Raspberry Pi Pico GP16 to NeoPixel ring DIN.
- Wire 2. Connect Raspberry Pi Pico VBUS to NeoPixel ring VCC.
- Wire 3. Connect Raspberry Pi Pico GND to NeoPixel ring GND.
- Paste the MicroPython code. Paste the MicroPython code below into the code editor.
- Run it. Press Run. The bit timing comes from a PIO state machine, not the CPU: the Pico special trick.
MicroPython code
# NeoPixel ring on GP16, driven by the rp2 port's PIO state machine.
from machine import Pin
import neopixel
import time
COUNT = 12
ring = neopixel.NeoPixel(Pin(16), COUNT)
def wheel(pos):
# 0-255 around the colour wheel
if pos < 85:
return (255 - pos * 3, pos * 3, 0)
if pos < 170:
pos -= 85
return (0, 255 - pos * 3, pos * 3)
pos -= 170
return (pos * 3, 0, 255 - pos * 3)
step = 0
while True:
for i in range(COUNT):
r, g, b = wheel((i * 256 // COUNT + step) & 255)
ring[i] = (r // 4, g // 4, b // 4)
ring.write()
step = (step + 8) & 255
time.sleep_ms(40)
What to try
The bit timing comes from a PIO state machine, not the CPU: the Pico special trick.
Frequently asked questions
How do I wire the NeoPixel Ring project on a Raspberry Pi Pico?
Make 3 connections: Raspberry Pi Pico GP16 to NeoPixel ring DIN; Raspberry Pi Pico VBUS to NeoPixel ring VCC; Raspberry Pi Pico GND to NeoPixel ring GND.
What parts do I need for this Raspberry Pi Pico project?
A Raspberry Pi Pico and a NeoPixel ring.
Can I simulate this Raspberry Pi Pico project online for free?
Yes. The BitForBytes Embedded Lab runs this exact circuit and MicroPython code in your browser for free, with no install and no hardware. The RP2040 is emulated and runs the official firmware.
What does the code do?
The neopixel module drives a 12-pixel ring on GP16 with the RP2040 PIO.
More Raspberry Pi Pico projects
- Raspberry Pi Pico LED Blink: Wiring, Code and Simulator
- Raspberry Pi Pico Push Button: Wiring, Code and Simulator
- Raspberry Pi Pico ADC + PWM LED Dimmer: Wiring, Code and Simulator
- Raspberry Pi Pico DHT22 Sensor: Wiring, Code and Simulator
- Raspberry Pi Pico I2C LCD: Wiring, Code and Simulator
- Raspberry Pi Pico LED Blink: Wiring, Code and Simulator