Hello guys, im completely new to arduino programing leds and i found this amazing forum, i simply modified the meteor rain parameters to make it look like a flash passing through and some fade behind it, my question is can i make this loop restart quicker ? i mean when all the effect go through the strip it takes like 2sec to restart. here is the code. thank you very much for any help
#include
#define PIN 2
#define NUM_LEDS 60
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
// ---------------------------------------------------
void loop() {
meteorRain(0xff, 0x00, 0x00, 4, 22, true, 8);
}
void meteorRain(byte red, byte green, byte blue, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay) {
;
for (int i = 0; i < NUM_LEDS + NUM_LEDS; i++) {
// fade brightness all LEDs one step
for (int j = 0; j < NUM_LEDS; j++) {
if ((!meteorRandomDecay) || (random(10) > 5)) {
fadeToBlack(j, meteorTrailDecay);
}
}
// draw meteor
for (int j = 0; j < meteorSize; j++) {
if ((i - j < NUM_LEDS) && (i - j >= 0)) {
setPixel(i - j, red, green, blue);
}
}
showStrip();
delay(SpeedDelay);
}
}
void fadeToBlack(int ledNo, byte fadeValue) {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
uint32_t oldColor;
uint8_t r, g, b;
int value;
oldColor = strip.getPixelColor(ledNo);
r = (oldColor & 0x00ff0000 UL) >> 16;
g = (oldColor & 0x0000ff00 UL) >> 8;
b = (oldColor & 0x000000ff UL);
r = (r <= 10) ? 0 : (int) r - (r * fadeValue / 250);
g = (g <= 10) ? 0 : (int) g - (g * fadeValue / 250);
b = (b <= 10) ? 0 : (int) b - (b * fadeValue / 250);
strip.setPixelColor(ledNo, r, g, b);
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
leds[ledNo].fadeToBlackBy(fadeValue);
#endif
}
// -----------------------------------------
void showStrip() {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.show();
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
FastLED.show();
#endif
}
void setPixel(int Pixel, byte red, byte green, byte blue) {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.setPixelColor(Pixel, strip.Color(red, green, blue));
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
leds[Pixel].r = red;
leds[Pixel].g = green;
leds[Pixel].b = blue;
#endif
}
void setAll(byte red, byte green, byte blue) {
for (int i = 0; i < NUM_LEDS; i++) {
setPixel(i, red, green, blue);
}
showStrip();
}