CCNAP

TPL-05Templates/NeoPixel Matrix Rainbow

NeoPixel Matrix Rainbow

8×8 WS2812B NeoPixel matrix running a diagonal rainbow wave. Each pixel is addressed by row and column via Adafruit NeoPixel.

Open in Playgroundintermediate · NeoPixel · WS2812B · matrix · RGB · animation
intermediate

FIG. 1NeoPixel Matrix Rainbow · circuitTPL-05

02Sketch

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);
}

03Components

  • 01Arduino Uno
  • 02NeoPixel Matrix 8×8 (wokwi-neopixel-matrix)

04Wiring

Component pinArduino pin
VCC5V
GNDGND
DIN (Data In)Pin 6

All templates

Ready when you are

Have a circuit in mind?

No hardware, no installs — a browser is enough.