neoled-rgb.ino
The Nano ESP32 embeds a WS2812 RGB LED on pin 48: this rainbow makes it breathe with no external part. Neopixels demand a strict 800 kHz timing stream, generated here by the ESP32 RMT peripheral.
Hardware
An Arduino Nano ESP32 (dual-core ESP32-S3, 2.4 GHz Wi-Fi + Bluetooth Low Energy, Nano-compatible physical pinout, native USB, 3.3 V pins only). Bare Nano ESP32 — the LED is onboard; for an external strip, free GPIO + dedicated supply.
Wiring
Nothing for the onboard LED. External WS2812 strip: DATA→GPIO pin, common→GND, VCC supplied separately beyond ~20 LEDs.
How it works
Adafruit_NeoPixel builds the GRB stream and show() blasts it through the RMT peripheral (hardware timing). The colour wheel advances 1/768th each loop pass.
Running it
Install the Arduino ESP32 Boards package (or follow the official Nano ESP32 guide), select Arduino Nano ESP32, upload. Pins are 3.3 V: never feed 5 V into an input. The serial monitor uses native USB.
Variants
Use the esp32 core neopixel class (neopixelWrite) for a one-liner, or drive a strip as a sound-level indicator.
neoled-rgb.ino
// La Nano ESP32 embarque une LED RGB adressable (WS2812, broche 48).
// Pilotee ici sans library lourde, via le driver RMT du coeur esp32.
#include <Adafruit_NeoPixel.h> // ou le driver neopixelClass du core
Adafruit_NeoPixel rgb(1, 48, NEO_GRB + NEO_KHZ800);
unsigned long dernier = 0;
int phase = 0;
void setup() {
Serial.begin(115200);
rgb.begin();
rgb.setBrightness(40); // attention : une WS2812 a fond tire ~50 mA
}
void loop() {
if (millis() - dernier < 30) return;
dernier = millis();
phase = (phase + 1) % 768;
// roue chromatique en trois tiers de 256 pas
uint8_t r = 0, v = 0, b = 0;
if (phase < 256) { r = 255 - phase; v = phase; }
else if (phase < 512) { v = 511 - phase; b = phase - 255; }
else { b = 767 - phase; r = phase - 511; }
rgb.setPixelColor(0, rgb.Color(r, v, b));
rgb.show(); // impulsion RMT : trame 800 kHz
}