NeoPixel Reference
A single WS2812B addressable RGB LED, driven over one data line and chainable via DOUT.
Pin names
| Name | Description |
|---|---|
| VDD | Power (5V) |
| VSS | Ground |
| DIN | Data In — connect to a GPIO pin |
| DOUT | Data Out — chain to the next pixel's DIN |
Attributes
This component has no configurable attributes.
Usage
Connect VDD to 5V, VSS to GND, and DIN to a GPIO pin. Drive it with the Adafruit NeoPixel library.
#include <Adafruit_NeoPixel.h>
#define PIN 6
#define NUMPIXELS 1
Adafruit_NeoPixel pixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
pixel.begin();
pixel.setBrightness(100);
}
void loop() {
uint32_t colors[] = {
pixel.Color(255, 0, 0), // red
pixel.Color(0, 255, 0), // green
pixel.Color(0, 0, 255), // blue
pixel.Color(255, 255, 0), // yellow
};
for (auto c : colors) {
pixel.setPixelColor(0, c);
pixel.show();
delay(600);
}
}
Examples
| Description | Attrs |
|---|---|
| Single pixel | {} |
See also
- LED Ring — 16 NeoPixels pre-arranged in a ring
- NeoPixel Matrix — NeoPixels arranged in a grid
- RGB LED — discrete R/G/B LED requiring three separate GPIOs instead of one data line