Hello Hans!
Firs of all i want to thank you a lot for this forum. It’s so helpful. Its been over a month that i am working on my project and i am having a hard time to make the code.
So i have 32 different LED strips each with 300 LEDs and arduino mega which has 32 digital outputs (pin 22 – pin 53.)
I will try to explain the diagram that i have:
16L 16R
15L 15R
14L 14R
13L 13R
12L 12R
11L 11R
10L 10R
9L 9R
8L 8R
7L 7R
6L 6R
5L 5R
4L 4R
3L 3R
2L 2R
1L 1R
All my LED strips are connected to power supplies. All the power supplies have same ground which is also connected to arduino.I am trying to make it as a light show. If you take a look on this video you will see on 1:30 which effect i want to make.
Pretty much a strobe light that goes fro 1 to 16 from right side than from left side.Now, instead of writing down individually all 32 outputs, is there any way i can make it nicer maybe by using digitalwrite and pinMode?So this is what i have so far and i stoped on strobe1:
_________________________________________________________________________________
#include “FastLED.h”
#define NUM_LEDS 300
#define NUM_STRIPS 32
CRGB leds[NUM_LEDS];
uint8_t gBrightness = 1;
void setup()
{
FastLED.addLeds<WS2812B, 22>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 23>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 24>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 25>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 26>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 27>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 28>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 29>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 30>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 31>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 32>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 33>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 34>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 35>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 36>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 37>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 38>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 39>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 40>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 41>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 42>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 43>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 44>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 45>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 46>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 47>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 48>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 49>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 50>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 51>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 52>(leds, NUM_LEDS);
FastLED.addLeds<WS2812B, 53>(leds, NUM_LEDS);
}
void loop() {
Strobe(0xff, 0xff, 0x00, 1, 50, 500);
Strobe1(0xff, 0xff, 0x00, 1, 50, 500);
Strobe2(0xff, 0xff, 0x00, 1, 50, 500);
Strobe3(0xff, 0xff, 0x00, 1, 50, 500);
Strobe4(0xff, 0xff, 0x00, 1, 50, 500);
Strobe5(0xff, 0xff, 0x00, 1, 50, 500);
Strobe6(0xff, 0xff, 0x00, 1, 50, 500);
Strobe7(0xff, 0xff, 0x00, 1, 50, 500);
Strobe8(0xff, 0xff, 0x00, 1, 50, 500);
Strobe9(0xff, 0xff, 0x00, 1, 50, 500);
Strobe10(0xff, 0xff, 0x00, 1, 50, 500);
Strobe11(0xff, 0xff, 0x00, 1, 50, 500);
Strobe12(0xff, 0xff, 0x00, 1, 50, 500);
Strobe13(0xff, 0xff, 0x00, 1, 50, 500);
Strobe14(0xff, 0xff, 0x00, 1, 50, 500);
Strobe15(0xff, 0xff, 0x00, 1, 50, 500);
Strobe16(0xff, 0xff, 0x00, 1, 50, 500);
Strobe17(0xff, 0xff, 0x00, 1, 50, 500);
Strobe18(0xff, 0xff, 0x00, 1, 50, 500);
Strobe19(0xff, 0xff, 0x00, 1, 50, 500);
Strobe20(0xff, 0xff, 0x00, 1, 50, 500);
Strobe21(0xff, 0xff, 0x00, 1, 50, 500);
Strobe22(0xff, 0xff, 0x00, 1, 50, 500);
Strobe23(0xff, 0xff, 0x00, 1, 50, 500);
Strobe24(0xff, 0xff, 0x00, 1, 50, 500);
Strobe25(0xff, 0xff, 0x00, 1, 50, 500);
Strobe26(0xff, 0xff, 0x00, 1, 50, 500);
Strobe27(0xff, 0xff, 0x00, 1, 50, 500);
Strobe28(0xff, 0xff, 0x00, 1, 50, 500);
Strobe29(0xff, 0xff, 0x00, 1, 50, 500);
Strobe30(0xff, 0xff, 0x00, 1, 50, 500);
Strobe31(0xff, 0xff, 0x00, 1, 50, 500);
}
void Strobe(byte red, byte green, byte blue, int StrobeCount, int FlashDelay, int EndPause){
for(int j = 0; j < StrobeCount; j++) {
setAll(red,green,blue);
showStrip1();
delay(FlashDelay);
setAll(0,0,0);
showStrip1();
delay(FlashDelay);
}
delay(EndPause);
}
void Strobe1(byte red, byte green, byte blue, int StrobeCount, int FlashDelay, int EndPause){
for(int j = 0; j < StrobeCount; j++) {
setAll(red,green,blue);
showStrip2();
delay(FlashDelay);
setAll(0,0,0);
showStrip2();
delay(FlashDelay);
}
delay(EndPause);
}
void showStrip1() {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.show();
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
FastLED[0].showLeds(gBrightness);
#endif
}
void showStrip2() {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.show();
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
FastLED[1].showLeds(gBrightness);
#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);
}
}
_________________________________________________________________________
//This is how i tried to make the code smaller:
#include “FastLED.h”
#define NUM_LEDS 300
CRGB leds[NUM_LEDS];
uint8_t gBrightness = 1;
void setup() {
for(int z=22; z<=53; z++) {
pinMode(z, OUTPUT);
FastLED.addLeds<WS2812B, z>(leds, NUM_LEDS); // <- Right here i am getting and error stating that the value z is not
// is not usable in a constant expression
}
}
void loop() {
Strobe(0xff, 0x00, 0x00, 1, 50, 100);
for(int z=22; z<=53; z++) {
digitalWrite(z, HIGH);
delay(10);
digitalWrite(z, LOW);
}
}
void Strobe(byte red, byte green, byte blue, int StrobeCount, int FlashDelay, int EndPause){
for(int j = 0; j < StrobeCount; j++) {
setAll(red,green,blue);
showStrip();
delay(FlashDelay);
setAll(0,0,0);
showStrip();
delay(FlashDelay);
}
delay(EndPause);
}
void showStrip() {
for(int z=22; z<=53; z++) {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.show();
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
FastLED[z].showLeds(gBrightness);
#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);
}
}
I would much appreciate you help!