Hi everyone - noob question time.
I have a small led RGB strip program where a led chases up and down the strip changing colour each time how can I implement a global delay so I dont have to change each delay in the program
[code]
//Leds chase backwards and forwards along strip
//
#include <FastLED.h>
#define NUM_LEDS 60
#define DATA_PIN 5
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
}
void loop()
{
for(int dot = 0; dot < NUM_LEDS; dot++) {
//fadeToBlackBy( leds, NUM_LEDS, 20);
leds[dot] = CRGB::Yellow;
FastLED.show();
// clear this led for the next time around the loop
//fadeToBlackBy( leds, NUM_LEDS, 100);
leds[dot] = CRGB::Black;
delay(50);
}
// chase backward Orange
for(int dot=NUM_LEDS ; dot >=0 ; dot--){
leds[dot] = CRGB::Red;
FastLED.show();
//fadeToBlackBy( leds, NUM_LEDS, 100);
leds[dot] = CRGB::Black;
delay(50);
}
// chase forward blue
for(int dot = 0; dot < NUM_LEDS; dot++) {
leds[dot] = CRGB::Orange;
FastLED.show();
// clear this led for the next time around the loop
leds[dot] = CRGB::Black;
delay(50);
}
// chase backward Orange
for(int dot=NUM_LEDS ; dot >=0 ; dot--){
leds[dot] = CRGB::Purple;
FastLED.show();
leds[dot] = CRGB::Black;
delay(50);
}
// chase forward blue
for(int dot = 0; dot < NUM_LEDS; dot++) {
leds[dot] = CRGB::Blue;
FastLED.show();
// clear this led for the next time around the loop
leds[dot] = CRGB::Black;
delay(50);
}
// chase backward Purple
for(int dot=NUM_LEDS ; dot >=0 ; dot--){
leds[dot] = CRGB::Green;
FastLED.show();
leds[dot] = CRGB::Black;
delay(50);
}}
[/code]