CNAP
03 / Templates · intermediate

LED RING RAINBOW

Open in Playground

16-pixel NeoPixel ring running a spinning rainbow chase via FastLED. Data driven from a single pin using the WS2812B protocol.

intermediateNeoPixelWS2812BFastLEDRGBanimation
Circuit
Code
sketch.inoArduino C++
22 lines
// LED Ring — spinning rainbow chase (FastLED)
#include <FastLED.h>

#define NUM_LEDS  16
#define DATA_PIN  6

CRGB leds[NUM_LEDS];

void setup() {
  FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
  FastLED.setBrightness(80);
}

void loop() {
  static uint8_t hue = 0;
  for (int i = 0; i < NUM_LEDS; i++) {
    leds[i] = CHSV(hue + (i * 256 / NUM_LEDS), 255, 255);
  }
  FastLED.show();
  hue++;
  delay(20);
}
Components
  • Arduino Uno
    01
  • LED Ring (wokwi-led-ring)
    02
Wiring
Component PinArduino Pin
VCC5V
GNDGND
DIN (Data In)Pin 6