🛠 OctoWS2811 : piloter 8 rubans WS2812 en parallèle par DMA (presque zéro CPU)

Teensy 3.2 · intermediaire · Schéma : IMG-teensy-32-intermediaire-5-teensy32-octows2811-mur-led.svg — Teensy 3.2 reliée par une nappe à un buffer 74HCT245 (OctoWS2811 Adaptor) d'où partent 8 rubans WS2812 parallèles ; broches 22, 14, 7, 8, 6, 20, 21, 5 annotées sur la carte ; en médaillon, un mur LED 64x64 animé et l'alimentation 5 V dédiée avec condensateur de découplage.

Objectives

Understand why the Teensy 3.2 is the queen of LED walls: the OctoWS2811 library drives 8 WS2811/WS2812 strips in parallel via DMA — up to 8800 LEDs refreshed at 30 Hz, ~4000 LEDs recommended per Teensy 3.2, 1000 LEDs updated in 3.8 ms (theoretically 240 Hz) — with almost zero CPU usage: show returns in 2 µs. You will wire 8 strips (or just one to start) with the essential 74HCT245 buffer, then look at WS2812Serial and SmartMatrix alternatives.

Hardware

Complete Code

API verified on the official OctoWS2811 page:

#include <OctoWS2811.h>

// 8 rubans de 256 WS2812B sur les broches 22,14,7,8,6,20,21,5 (fixes)
const int ledsPerStrip = 256;

DMAMEM int displayMemory[ledsPerStrip * 6]; // double buffer DMA (6 int/LED)
int drawingMemory[ledsPerStrip * 6];        // back buffer que votre code dessine

const int config = WS2811_GRB | WS2811_800kHz; // ordre des couleurs + debit

OctoWS2811 leds(ledsPerStrip, displayMemory, drawingMemory, config);

void setup {
  leds.begin;
  leds.show; // efface toutes les LED
}

void loop {
  while (leds.busy) { }            // attend la fin du transfert DMA precedent
  for (int i = 0; i < ledsPerStrip * 8; i++) {
    leds.setPixel(i, 120, 0, 0);     // rouge ; setPixel(num, r, g, b)
  }
  leds.show;                       // lance la MAJ DMA, revient en ~2 us
  // Le CPU est libre ici : 1000 LED prennent 3,8 ms au total
  delay(16);
}

Expected Verification

The 8 strips light up in red synchronously. Measure the CPU usage: it is marginal — the WS2812 signal synthesis is done by the DMA, not by your loop. The while (leds.busy) { } prevents overwriting a buffer during a transfer. For a complete video wall, the VideoDisplay example in the library streams PC video to multi-Teensy networks with frame synchronization (1920 LEDs shown on two boards in the PJRC demo, scalable to several thousand).

Alternatives Depending on the Project

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials