03 / Templates · intermediate
NEOPIXEL MATRIX RAINBOW
Open in Playground8×8 WS2812B NeoPixel matrix running a diagonal rainbow wave. Each pixel is addressed by row and column via Adafruit NeoPixel.
intermediateNeoPixelWS2812BmatrixRGBanimation
sketch.inoArduino C++
28 lines
// NeoPixel Matrix 8×8 — diagonal rainbow wave
#include <Adafruit_NeoPixel.h>
#define DATA_PIN 6
#define ROWS 8
#define COLS 8
#define NUMPIXELS (ROWS * COLS)
Adafruit_NeoPixel matrix(NUMPIXELS, DATA_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
matrix.begin();
matrix.setBrightness(60);
}
void loop() {
static uint16_t offset = 0;
for (int row = 0; row < ROWS; row++) {
for (int col = 0; col < COLS; col++) {
uint16_t hue = offset + (uint16_t)(row + col) * 4096;
uint32_t color = matrix.gamma32(matrix.ColorHSV(hue, 255, 200));
matrix.setPixelColor(row * COLS + col, color);
}
}
matrix.show();
offset += 512;
delay(30);
}- Arduino Uno01
- NeoPixel Matrix 8×8 (wokwi-neopixel-matrix)02
| Component Pin | Arduino Pin |
|---|---|
| VCC | 5V |
| GND | GND |
| DIN (Data In) | Pin 6 |