#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#define PIN 4 // Data pin to RGB matrix (GPIO4 works well on ESP32-C3)
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(
32, 8, PIN,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_ROWS + NEO_MATRIX_PROGRESSIVE,
NEO_GRB + NEO_KHZ800);
unsigned long lastMillis = 0;
int mode = 0;
void setup() {
matrix.begin();
matrix.setBrightness(60);
matrix.fillScreen(0);
matrix.show();
}
void loop() {
if (millis() - lastMillis > 5000) { // change art every 5s
mode = (mode + 1) % 4;
lastMillis = millis();
matrix.fillScreen(0);
}
switch(mode) {
case 0: gradientStripes(); break;
case 1: checkerboard(); break;
case 2: rainbowDiagonal(); break;
case 3: scrollingText(); break;
}
matrix.show();
}
// --- Art Modes ---
void gradientStripes() {
for (int x=0; x<32; x++) {
uint16_t color = matrix.Color(x*8, 255-x*8, (x*4)%255);
for (int y=0; y<8; y++) {
matrix.drawPixel(x,y,color);
}
}
}
void checkerboard() {
for (int x=0; x<32; x++) {
for (int y=0; y<8; y++) {
if ((x+y)%2==0) matrix.drawPixel(x,y,matrix.Color(255,0,0));
else matrix.drawPixel(x,y,matrix.Color(0,0,255));
}
}
}
void rainbowDiagonal() {
for (int x=0; x<32; x++) {
for (int y=0; y<8; y++) {
uint16_t color = matrix.Color((x*8)%255,(y*32)%255,((x+y)*16)%255);
matrix.drawPixel(x,y,color);
}
}
}
void scrollingText() {
static int x=32;
matrix.setTextColor(matrix.Color(0,255,255));
matrix.setCursor(x,1);
matrix.print("AI Centre");
x--;
if (x<-60) x=32;
}
Loading
xiao-esp32-c3
xiao-esp32-c3