/*
8x8 NeoPixel Matrix Demo
Arduino Nano + WS2812B 64 LED Matrix
Library Required:
Adafruit NeoPixel
*/
#include <Adafruit_NeoPixel.h>
#define LED_PIN D10 // Data pin to matrix
#define LED_COUNT 64 // 8x8 = 64 pixels
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
uint8_t mode = 0;
unsigned long lastChange = 0;
const unsigned long demoTime = 5000; // 5 seconds per effect
// =======================================================
void setup() {
strip.begin();
strip.setBrightness(180);
strip.show();
}
// =======================================================
void loop() {
switch (mode) {
case 0: rainbowFill(); break;
case 1: colorWaves(); break;
case 2: breatheEffect(); break;
case 3: meteorRain(); break;
case 4: theaterChaseRainbow(); break;
case 5: sparkleEffect(); break;
}
if (millis() - lastChange > demoTime) {
lastChange = millis();
mode++;
if (mode > 5) mode = 0;
strip.clear();
strip.show();
}
}
// =======================================================
// Rainbow Fill (all pixels active)
// =======================================================
void rainbowFill() {
static uint16_t j = 0;
for (int i = 0; i < LED_COUNT; i++) {
strip.setPixelColor(i, Wheel((i * 256 / LED_COUNT + j) & 255));
}
strip.show();
j++;
delay(20);
}
// =======================================================
// Color Waves across matrix
// =======================================================
void colorWaves() {
static int pos = 0;
strip.clear();
for (int t = 0; t < 8; t++) {
int idx = (pos - t + LED_COUNT) % LED_COUNT;
uint8_t b = 255 - t * 30;
strip.setPixelColor(idx, strip.Color(0, b, 255));
}
strip.show();
pos++;
if (pos >= LED_COUNT) pos = 0;
delay(60);
}
// =======================================================
// Breathing Effect (whole matrix)
// =======================================================
void breatheEffect() {
for (int b = 10; b < 255; b += 5) {
strip.fill(strip.Color(b, 0, b));
strip.show();
delay(15);
}
for (int b = 255; b > 10; b -= 5) {
strip.fill(strip.Color(b, 0, b));
strip.show();
delay(15);
}
}
// =======================================================
// Meteor Rain across matrix
// =======================================================
void meteorRain() {
static int pos = 0;
for (int i = 0; i < LED_COUNT; i++) {
uint32_t c = strip.getPixelColor(i);
uint8_t r = (c >> 16) & 0xFF;
uint8_t g = (c >> 8) & 0xFF;
uint8_t b = c & 0xFF;
r = r > 20 ? r - 20 : 0;
g = g > 20 ? g - 20 : 0;
b = b > 20 ? b - 20 : 0;
strip.setPixelColor(i, r, g, b);
}
strip.setPixelColor(pos, 255, 180, 80);
strip.show();
pos++;
if (pos >= LED_COUNT) pos = 0;
delay(40);
}
// =======================================================
// Theater Chase Rainbow
// =======================================================
void theaterChaseRainbow() {
static int step = 0;
strip.clear();
for (int i = 0; i < LED_COUNT; i++) {
if ((i + step) % 3 == 0) {
strip.setPixelColor(i, Wheel((i * 10 + step * 10) & 255));
}
}
strip.show();
step++;
delay(80);
}
// =======================================================
// Sparkle Effect
// =======================================================
void sparkleEffect() {
for (int i = 0; i < LED_COUNT; i++) {
uint32_t c = strip.getPixelColor(i);
uint8_t r = (c >> 16) & 0xFF;
uint8_t g = (c >> 8) & 0xFF;
uint8_t b = c & 0xFF;
r = r > 30 ? r - 30 : 0;
g = g > 30 ? g - 30 : 0;
b = b > 30 ? b - 30 : 0;
strip.setPixelColor(i, r, g, b);
}
int pixel = random(LED_COUNT);
strip.setPixelColor(pixel, random(256), random(256), random(256));
strip.show();
delay(50);
}
// =======================================================
// Color Wheel
// =======================================================
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if (WheelPos < 85) {
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if (WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
Loading
xiao-esp32-c3
xiao-esp32-c3
FPS: 0
Power: 0.00W
Power: 0.00W
https://wokwi.com/projects/468264906400489473
AI CENTRE NANDURBAR