Thanks for your continuing replies,
I'm sure your idea of a cyclon is clearer than mine but I think of it as a night rider effect.
What I'd like to be able to write is a sort of adaptation of this effect.
Here's a video of my setup with the exact effect I'd like to understand:
and here's the code:
#include <Adafruit_NeoPixel.h>
#define PIN 6
#define NUM_LEDS 15
// 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() {
colorWipe(0xff,0xa2,0x00, 40);
colorWipe(0x00,0x00,0x00, 5);
}
void colorWipe(byte red, byte green, byte blue, int SpeedDelay) {
for(uint16_t i=0; i<NUM_LEDS; i++) {
setPixel(i, red, green, blue);
showStrip();
delay(SpeedDelay);
}
}
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();
}
This might be known as a colour wipe. As I understand it, it is doing the same thing twice? One cycle lights the leds in sequence and the second cycle turns them off. In order to create the effect I want, I have increased the speed of the second 'black' led cycle:
void loop() {
colorWipe(0xff,0xa2,0x00, 40);
colorWipe(0x00,0x00,0x00, 5);
This is because I want the leds to simply 'turn off' as quickly as possible.
When it comes to the first for loop, am I right in saying that the variable i (set pixel) which starts at 0 and then continues until the end of the strip (NUM_LEDS) in increments of 1 (i++)??
Again, I'm not trying to rush, just showing what I'm trying to do and the extent of my understanding of the code it requires.
Kyle