LED Ring Reference
A 16-pixel WS2812B addressable LED ring, driven over a single data line and chainable via DOUT.
Pin names
| Name | Description |
|---|---|
| VCC | Power (5V) |
| GND | Ground |
| DIN | Data In — connect to a GPIO pin |
| DOUT | Data Out — chain to the next ring/strip's DIN |
Attributes
This component has no configurable attributes.
Usage
Connect VCC to 5V, GND to GND, and DIN to a GPIO pin. Drive it with the FastLED or Adafruit NeoPixel library using the WS2812B protocol.
#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);
}
Examples
| Description | Attrs |
|---|---|
| Default 16-pixel ring | {} |
See also
- NeoPixel — single addressable pixel using the same WS2812B protocol
- NeoPixel Matrix — addressable pixels arranged in a grid
- LED Bar Graph — discrete LEDs driven individually instead of over a data line