# Chapter 6: NeoPixel – Driving WS2812 LEDs with RP2040 PIO in Ada

**URL:** https://forum.ada-lang.io/t/chapter-6-neopixel-driving-ws2812-leds-with-rp2040-pio-in-ada/4384
**Category:** Releases
**Tags:** embedded, ada, pio, pi-pico, raspberry
**Created:** [May 1, 2026, 6:07pm UTC](https://forum.ada-lang.io/t/chapter-6-neopixel-driving-ws2812-leds-with-rp2040-pio-in-ada/4384 "2026-05-01T18:07:21Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![krischik](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/krischik/32/420_2.png) [@krischik](https://forum.ada-lang.io/u/krischik)
#### Post date: [May 1, 2026, 6:07pm UTC](https://forum.ada-lang.io/t/chapter-6-neopixel-driving-ws2812-leds-with-rp2040-pio-in-ada/4384/1 "2026-05-01T18:07:21Z")

</div>

Hello everyone,

I have just published **Chapter 6: NeoPixel** of the _Raspberry Pi Pico Ada Tutorial_.

> **[Chapter 6: NeoPixel](https://pi-ada-tutorial.sourceforge.io/pico_ada_c06_neopixel/)**
>
> Learn how to drive WS2812 (NeoPixel) LEDs on the Raspberry Pi Pico using the RP2040 PIO in Ada. Includes a square-wave diagnostic, fixes for the official ws2812\_demo, and two complete animation sketches.

In this chapter I go beyond the usual “just use the library” approach and explain how the WS2812 protocol actually works and why the RP2040’s PIO is perfect for it. You will see:

- A simple square-wave generator used as a learning and debugging tool
- The four gotchas that had me staring at the oscilloscope for far too long
- A corrected and fully commented version of Jeremy Grosser’s ws2812\_demo
- Two complete animation sketches (Sketch\_06\_1\_LED\_Pixel and Sketch\_06\_2\_Rainbow\_Light)

The chapter also contains a practical introduction to PIO programming and shows how to generate Ada code automatically with the official pioasm tool.

**New GNATdoc documentation** is available for both Pico and Pico 2:

- [https://pi-ada-tutorial.sourceforge.io/gnatdoc/pico\_ada\_doc/](https://pi-ada-tutorial.sourceforge.io/gnatdoc/pico_ada_doc/)
- [https://pi-ada-tutorial.sourceforge.io/gnatdoc/pico2\_ada\_doc/](https://pi-ada-tutorial.sourceforge.io/gnatdoc/pico2_ada_doc/)

Don’t forget the **Side Quests** either — they cover system setup, Alire, Visual Studio Code, hardware debugging, adding a reset button, and more.

As always, the full source code is on SourceForge and available as an Alire crate (in a few days).

Feedback and questions are very welcome!

Happy hacking, Martin

---

<div class="post-metadata">

### Author: ![AdaOrbit](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/adaorbit/32/879_2.png) [@AdaOrbit](https://forum.ada-lang.io/u/AdaOrbit)
#### Post date: [May 1, 2026, 7:06pm UTC](https://forum.ada-lang.io/t/chapter-6-neopixel-driving-ws2812-leds-with-rp2040-pio-in-ada/4384/2 "2026-05-01T19:06:43Z")

</div>

> When setting up a new shot I accidentally pluggedone the older (non-polarity-protected) 8-LED circular NeoPixel modules in the wrong way — data-in into V+, V+ into ground, and ground into an empty slot. It died instantly. 😭

I lost an led in a led matrix this way 😬  
Luckily those are cheap but that still sucked. Learned to check the polarity twice!
