/*
24 LED NeoPixel Ring Demo
Arduino Nano + WS2812B 24 LED Ring
Library Required:
Adafruit NeoPixel
*/
#include <Adafruit_NeoPixel.h>
#define LED_PIN D10
#define LED_COUNT 24
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(150);
strip.show();
}
// =======================================================
void loop() {
switch (mode) {
case 0: rainbowCycle(); break;
case 1: colorChase(); break;
case 2: breatheEffect(); break;
case 3: meteorRain(); break;
case 4: theaterChaseRainbow(); break;
case 5: sparkleEffect(); break;
case 6: rainbowFade(); break;
case 7: pulseCenterOut(); break;
case 8: knightRider(); break;
case 9: twinkleStars(); break;
case 10: dualColorWipe(); break;
case 11: larsonScannerRainbow(); break;
case 12: confetti(); break;
case 13: gradientRotate(); break;
case 14: colorBounce(); break;
case 15: waveMotion(); break;
case 16: rainbowBounce(); break;
case 17: breathingRainbow(); break;
case 18: lightningFlash(); break;
case 19: randomBurst(); break;
case 20: rainbowMeteor(); break;
case 21: dualMeteor(); break;
case 22: rainbowSparkle(); break;
case 23: colorExplosion(); break;
case 24: rainbowExplosion(); break;
case 25: rotatingDots(); break;
case 26: rainbowRotatingDots(); break;
case 27: heartbeatPulse(); break;
}
if (millis() - lastChange > demoTime) {
lastChange = millis();
mode++;
if (mode > 27) mode = 0;
strip.clear();
strip.show();
}
}
// =======================================================
// Original 6 Animations
// =======================================================
void rainbowCycle() { /* ... your original code ... */ }
void colorChase() { /* ... your original code ... */ }
void breatheEffect() { /* ... your original code ... */ }
void meteorRain() { /* ... your original code ... */ }
void theaterChaseRainbow() { /* ... your original code ... */ }
void sparkleEffect() { /* ... your original code ... */ }
// =======================================================
// New Animations (26 functions)
// =======================================================
void rainbowFade() { /* code from batch 2 */ }
void pulseCenterOut() { /* code from batch 2 */ }
void knightRider() { /* code from batch 2 */ }
void twinkleStars() { /* code from batch 2 */ }
void dualColorWipe() { /* code from batch 2 */ }
void larsonScannerRainbow() { /* code from batch 2 */ }
void confetti() { /* code from batch 2 */ }
void gradientRotate() { /* code from batch 2 */ }
void colorBounce() { /* code from batch 2 */ }
void waveMotion() { /* code from batch 2 */ }
void rainbowBounce() { /* code from batch 3 */ }
void breathingRainbow() { /* code from batch 3 */ }
void lightningFlash() { /* code from batch 3 */ }
void randomBurst() { /* code from batch 3 */ }
void rainbowMeteor() { /* code from batch 3 */ }
void dualMeteor() { /* code from batch 3 */ }
void rainbowSparkle() { /* code from batch 4 */ }
void colorExplosion() { /* code from batch 4 */ }
void rainbowExplosion() { /* code from batch 4 */ }
void rotatingDots() { /* code from batch 4 */ }
void rainbowRotatingDots() { /* code from batch 4 */ }
void heartbeatPulse() { /* code from batch 4 */ }
// =======================================================
// Color Wheel Helper
// =======================================================
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);
}
https://wokwi.com/projects/468263964047202305