ruban-neopixel.ino
WS2812s demand precise microseconds: the Mbed core generates them cleanly on the Portenta. A cyan head circling 16 LEDs serves as the first bench while the M7 does other work.
Hardware
An Arduino Portenta H7 (ST STM32H747 dual-core module Cortex-M7 @ 480 MHz + M4 @ 240 MHz, 8 MB SDRAM, high-density connector), powered by USB-C or 5 V. 1 strip of 16 NeoPixel LEDs + external 5 V supply.
Wiring
Data to D4 through 330 Ω, VCC to external 5 V, GND common with the Portenta (3.3 V logic accepted by WS2812s).
How it works
setPixelColor fills the buffer, show() sends the frame via timer/DMA. The modulo spins the head at ~16 Hz.
Running it
Arduino IDE with the « Arduino Mbed OS Portenta Boards » core: pick « Portenta H7 » (M7 core), the USB-C port, then Upload. The DFU mode M7/M4 selector also loads the M4 core.
Variants
Sync the animation with a reading (BMP280 pressure) or drive it from the M4 core over RPC.
ruban-neopixel.ino
// Ruban NeoPixel 16 LED sur D4 (Adafruit_NeoPixel sur core Mbed).
#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel ruban(16, 4, NEO_GRB + NEO_KHZ800);
unsigned long t0 = 0;
int tete = 0;
void setup() {
ruban.begin();
ruban.setBrightness(60);
Serial.begin(9600);
}
void loop() {
if (millis() - t0 < 60) return;
t0 = millis();
ruban.clear();
ruban.setPixelColor(tete, ruban.Color(0, 255, 120));
ruban.setPixelColor((tete + 1) % 16, ruban.Color(0, 90, 40));
ruban.show();
tete = (tete + 1) % 16;
}
// Les timing WS2812 sont generes par timers/DMA Mbed :
// fiables meme quand le M7 est charge ailleurs.