Hello all,
I'm working on my first Arduino Project, In this project there will be a video played on a Raspberry Pi. as soon as this video starts playing i'm sending a start command from the Raspberry to my arduino.
When the Arduino gets the start signal the LEDs will start moving from left to right.
Now my problem is that its takes quite some time to get the LEDs from left to right because one strip of LEDS contains 300 LEDS. So i tried to get two or three lines of LEDS running from left to right with a delay of a few seconds between them.
But i can't find how i can program that.
My current code is
#include "FastLED.h"
#define NUM_LEDS 303 //350
#define PIN 6
CRGB leds[NUM_LEDS];
int myCounter = 0;
int mySwitchPin = 4;
int pinvalue = 0;
void showStrip()
{
FastLED.show();
}
void setPixel(int Pixel, byte red, byte green, byte blue)
{
leds[Pixel].r = red;
leds[Pixel].g = green;
leds[Pixel].b = blue;
}
void setup()
{
FastLED.addLeds<WS2812B, PIN, GRB>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
pinMode(mySwitchPin, INPUT);
}
void loop()
{
meteorRain(0xff, 0xff, 0xff, 10, 50, false, 1);
pinvalue = digitalRead(mySwitchPin);
}
void meteorRain(byte red, byte green, byte blue, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay)
{
{
if (pinvalue == HIGH)
{
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)>1))
{
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();
myCounter = ++myCounter;
}
}
else
{
myCounter = 0;
}
}
}
void fadeToBlack(int ledNo, byte fadeValue) {
uint32_t oldColor;
uint8_t r, g, b;
int value;
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);
leds[ledNo].fadeToBlackBy(fadeValue);
}
I have tried to put in this part of the code in a second time, but when I don't have any compile problems anymore and the code is uploaded to the Arduino, nothing happens.
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)>1))
{
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);
}
}