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

QtyPartWhat it does
1Raspberry Pi Picothe microcontroller board
1NeoPixel ringA ring of WS2812 pixels. DIN from a pin, VCC to 5V, GND to GND.

Wiring

#FromTo
1Raspberry Pi Pico GP16NeoPixel ring DIN
2Raspberry Pi Pico VBUSNeoPixel ring VCC
3Raspberry Pi Pico GNDNeoPixel ring GND

Step by step

  1. Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Raspberry Pi Pico. No install or account is needed.
  2. Add the parts. Add a NeoPixel ring from the parts palette.
  3. Wire 1. Connect Raspberry Pi Pico GP16 to NeoPixel ring DIN.
  4. Wire 2. Connect Raspberry Pi Pico VBUS to NeoPixel ring VCC.
  5. Wire 3. Connect Raspberry Pi Pico GND to NeoPixel ring GND.
  6. Paste the MicroPython code. Paste the MicroPython code below into the code editor.
  7. 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