#include <Adafruit_NeoPixel.h>
#define LED_PIN 3 // Data pin
#define NUM_LEDS 30 // Total number of LEDs
#define BRIGHTNESS 150 // Brightness (0 to 255)
#define SMOKE_COLOR strip.Color(100, 100, 100) // Light gray smoke
Adafruit_NeoPixel strip(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.setBrightness(BRIGHTNESS);
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
driftSmokeEffect(12); // Control speed of drift
}
void driftSmokeEffect(int delayTime) {
int tailLength = 10; // How long the smoke trail is
// Drift right
for (int i = 0; i < NUM_LEDS + tailLength; i++) {
strip.clear();
for (int j = 0; j < tailLength; j++) {
int pixelIndex = i - j;
if (pixelIndex >= 0 && pixelIndex < NUM_LEDS) {
int fadeValue = map(j, 0, tailLength, 200, 20); // Brighter at head, dimmer at tail
uint32_t smokeFade = strip.Color(fadeValue, fadeValue, fadeValue);
strip.setPixelColor(pixelIndex, smokeFade);
}
}
strip.show();
delay(delayTime);
}
// Drift left
for (int i = NUM_LEDS + tailLength - 1; i >= 0; i--) {
strip.clear();
for (int j = 0; j < tailLength; j++) {
int pixelIndex = i - j;
if (pixelIndex >= 0 && pixelIndex < NUM_LEDS) {
int fadeValue = map(j, 0, tailLength, 200, 20);
uint32_t smokeFade = strip.Color(fadeValue, fadeValue, fadeValue);
strip.setPixelColor(pixelIndex, smokeFade);
}
}
strip.show();
delay(delayTime);
}
}