#include #include // --- config --- #define LED_PIN 3 // your NeoPixel data pin #define NUM_PIXELS 1 // change if you have more #define BRIGHTNESS 30 // 0..255 (keep modest if powered from USB) // Most WS2812/NeoPixel strips are GRB @ 800 kHz: #define PIXEL_TYPE (NEO_GRB + NEO_KHZ800) Adafruit_NeoPixel strip(NUM_PIXELS, LED_PIN, PIXEL_TYPE); static void solid(uint32_t c, uint16_t ms) { for (uint16_t i = 0; i < NUM_PIXELS; i++) strip.setPixelColor(i, c); strip.show(); delay(ms); } void setup() { strip.begin(); strip.setBrightness(BRIGHTNESS); strip.show(); // all off // Quick RGB sanity check (each color ~300 ms) solid(strip.Color(255, 0, 0), 300); // Red solid(strip.Color( 0, 255, 0), 300); // Green solid(strip.Color( 0, 0, 255), 300); // Blue solid(strip.Color( 0, 0, 0), 200); // Off } void loop() { // Smooth rainbow using HSV -> RGB with gamma correction static uint16_t hue = 0; // 0..65535 uint32_t c = strip.gamma32(strip.ColorHSV(hue)); for (uint16_t i = 0; i < NUM_PIXELS; i++) strip.setPixelColor(i, c); strip.show(); hue += 256; // step size (smaller = slower) delay(20); // frame rate (~50 FPS) }