Hello-
Thanks in advance for any help.
I'm working on a project that is using 12 individual led strips. I'm using the WS2815 12v versions. I have all the wiring and hardware figured out but am struggling a bit on the code. I'm using a MEGA so I can expand later if need be. I'm using the FastLED library example and it works great to make all 12 work at the same time. What I'm having an issue with is how to start and stop the code for each strip separately.
ie: Start PIN 1 code then Stop with delay
Start PIN 2 code then Stop with delay
.......and so on with all 12 strips
Want all PINs to use the same piece of code for the same effect on all 12 strips
The code below is what I have so far with all the strips working at the same time. Any assistance would be greatly appreciated. Thanks
Greg
#include "FastLED.h"
#define NUM_LEDS 37
CRGB leds[NUM_LEDS];
#define PIN 1
#define PIN 2
#define PIN 3
#define PIN 4
#define PIN 5
#define PIN 6
#define PIN 7
#define PIN 8
#define PIN 9
#define PIN 10
#define PIN 11
#define PIN 12
void setup(){
delay(5500);
FastLED.addLeds<WS2811, 1, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.addLeds<WS2811, 2, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.addLeds<WS2811, 3, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.addLeds<WS2811, 4, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.addLeds<WS2811, 5, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.addLeds<WS2811, 6, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.addLeds<WS2811, 7, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.addLeds<WS2811, 8, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.addLeds<WS2811, 9, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.addLeds<WS2811, 10, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.addLeds<WS2811, 11, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.addLeds<WS2811, 12, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
}
void loop() {
meteorRain(0xff,0xff,0xff,10, 64, true, 30);
}
void meteorRain(byte red, byte green, byte blue, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay) {
setAll(0,0,0);
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 & 0x00ff0000UL) >> 16;
g = (oldColor & 0x0000ff00UL) >> 8;
b = (oldColor & 0x000000ffUL);
r=(r<=10)? 0 : (int) r-(r*fadeValue/256);
g=(g<=10)? 0 : (int) g-(g*fadeValue/256);
b=(b<=10)? 0 : (int) b-(b*fadeValue/256);
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();
}