#include <Adafruit_NeoPixel.h>
#define PIN 5 // GPIO pin connected to LED matrix data input
#define NUMPIXELS 256 // 8 x 32 = 256 LEDs
Adafruit_NeoPixel strip(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
rainbowCycle(20);
// Customize colors here (R, G, B)
colorWipe(strip.Color(255, 105, 180), 50); // Hot pink wipe
colorWipe(strip.Color(0, 255, 255), 50); // Cyan wipe
colorWipe(strip.Color(255, 140, 0), 50); // Dark orange wipe
theaterChase(strip.Color(0, 255, 127), 50); // Spring green theater chase
blinkColor(strip.Color(75, 0, 130), 5, 300); // Indigo blink 5 times
}
// Generate rainbow colors across 0-255 positions
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);
}
// Rainbow cycle animation
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256; j++) {
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel((i * 256 / strip.numPixels() + j) & 255));
}
strip.show();
delay(wait);
}
}
// Color wipe animation: lights up LEDs one by one with a color
void colorWipe(uint32_t color, uint8_t wait) {
for (int i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, color);
strip.show();
delay(wait);
}
}
// Theater chase animation: moving dots effect
void theaterChase(uint32_t color, uint8_t wait) {
for (int j = 0; j < 10; j++) { // cycle 10 times
for (int q = 0; q < 3; q++) {
for (int i = 0; i < strip.numPixels(); i += 3) {
strip.setPixelColor(i + q, color); // turn every third pixel on
}
strip.show();
delay(wait);
for (int i = 0; i < strip.numPixels(); i += 3) {
strip.setPixelColor(i + q, 0); // turn every third pixel off
}
}
}
}
// Blink all LEDs with a color
void blinkColor(uint32_t color, uint8_t times, uint8_t wait) {
for (int i = 0; i < times; i++) {
strip.fill(color);
strip.show();
delay(wait);
strip.clear();
strip.show();
delay(wait);
}
}
Loading
esp32-s3-devkitc-1
esp32-s3-devkitc-1
https://wokwi.com/projects/new/esp32-s3
https://wokwi.com/projects/463066769149774849