LED array coding help

I have an array of WB2812B leds. 10x6=60leds. These are 6 cut led strips 10 leds each wired in series. I would like to animate 0-10 leds light then dim and the next set 11-20 would light up and dim creating a sequential light down the array.

I am new to arduino sketch coding any help would be appreciated. Thank you for your time.

I first suppose you already know how to program an Arduino. You should then get familiar with one of the LED control libraries available. FastLED is one of them. Install it and try the examples for only one of your strips.

Then find the way to dim the leds as you want.

When you feel confortable with one led strip, try to run a sketch with 2 strips. The different ways to do it is explained here.

Thank you for the reply and link to the examples. My project has in essence is 1 led strip on 1 pin but is soldiered together to look like an array. I am looking to animate each set of leds in a blinking on and off down the strips in a sequential fashion. I am still learning the programming code but understand quite a bit, just looking for the most efficient way to code this project as I am using ATTiny85.

I never tried the ATTiny85. Do you mean your strips are all connected in series ? Like a single strip of 60 leds?

Yes 60 leds in series but soldered in an array of 10x6 on going in 1 pin on ATtiny85. I use an Arduino Uno to program the ATiny85 from a breadboard. Works great for small projects. I have a 1972 VW Super Beetle that I am outfitting with sequential tail lights and animated turn signals with white driving lights. I currently have the turn signal animation just running down the 60 leds like a snaking light effect. I would like to light up 10 led at a time and down the array like you see in more and more modern vehicles.

Almost every car manufacture is turning to LED lights with animation. I guess the local police will be doing nothing but handing out those illegal tail light tickets. The lights I am designing will be no different than what is in modern cars today. I do see on Youtube more and more aftermarket car light kits that do fancy animations that flash show patterns marketed towards car shows and car clubs. I'm sure if you drove down the road with all your light beating to music in crazy animations you deserve a fine $$.

So if I understand well, from the point of view of the Arduino, you have a 60 led strip, numbered 0 to 59. For your animations, you just need to visualise the strip like this:

  • First line, leds number 0 to 9,
  • Second line, leds number 10 to 19
  • ...
  • Last line, leds number 50 to 59
    I can't help you more for now, until you have a code doing the led strip declaration and lighting the 60 leds at the same time.

Making this first code will help you handle the library and see how it works. Then I can help you customize your code, play with the delays or whatever you need, but I first need to see if the Attiny can handle the 60 leds and if you can declare the strip. There is help on the FastLED wiki.

To conect your leds, refer to this site, and the following pages (scroll down to see the blue rectangles to go the other pages).

Do not hesitate to PM me if you don't see me around, I'm not usually in this part of the forum...

This example shows how to control 8 leds using an Attiny85. I doubt the Attiny can provide enough current to feed 60 leds.
When all lit, and all white, 60 leds would require 60 x 0.06 = 3.6 A

So you will need another current source for your leds, connected like this :


So you also need a capacitor and a resistor.

Your code is quite complex, can you simplify it by removing what is not being used?

Power is not an issue. I am using a step down converter to power the leds and an optocoupler to handle the signal input from the vehicle. I have this currently running from a power supply of 13.5volts simulating the vehicle voltage.

This is the turn signal function. I believe I need to modify the code in the (int) to tell the strip to show 0-10 then delay then off and repeat for the next set 11-20 and so on...

int delayTurnLedAnim = 9; //delay of each led in turn light animation
int delayTurnLedOff = 250; //delay from animation to black (is used twice)

// turn signal function
if(stateTS != 0){

for(int dot = 0; dot < NUM_LEDS_PER_STRIP; dot++) {

leds[0][dot] = turnColor;
FastLED.show();

//delay(delayTurnLedAnim);
currentMillis = previousMillis = millis();
while(previousMillis + delayTurnLedAnim >= currentMillis){
FastLED.show();
currentMillis = millis();
}

}

//delay(delayTurnLedOff);
currentMillis = previousMillis = millis();
while(previousMillis + delayTurnLedOff >= currentMillis){
FastLED.show();
currentMillis = millis();
}

fill_solid(leds[0], NUM_LEDS_PER_STRIP, CRGB::Black);
FastLED.show();

//delay(delayTurnLedOff);
currentMillis = previousMillis = millis();
while(previousMillis + delayTurnLedOff >= currentMillis){
FastLED.show();
currentMillis = millis();
}

buttonStateTS = digitalRead(buttonPinTS);
stateTS++;
if(stateTS >= nrAnimAfterOff && buttonStateTS != HIGH){
stateTS = 0;
gBrtL = 0;
//delay(delayLedToDayLight);
currentMillis = previousMillis = millis();
while(previousMillis + delayLedToDayLight >= currentMillis){
FastLED.show();
currentMillis = millis();
}
}

OK, this is only a part of the code. You should post your code using the CODE tags, it's easier to read. It will look like this :

int delayTurnLedAnim = 9;     //delay of each led in turn light animation
int delayTurnLedOff = 250;    //delay from animation to black (is used twice)

// turn signal function
if(stateTS != 0){
        
    for(int dot = 0; dot < NUM_LEDS_PER_STRIP; dot++) {

        leds[0][dot] = turnColor;
        FastLED.show();

        //delay(delayTurnLedAnim);
        currentMillis = previousMillis = millis();
...

If I understand well, you want to light the 6 strings one after the other, turning a strip off before passing to the next.
Your code has several mistakes, such as this, which, AFAIK is not permitted:

currentMillis = previousMillis = millis();

Here is an example of a function doing the animation for the turn signal:

const int delayTurnLedAnim = 9;      //delay of each led in turn light animation
const int delayTurnLedOff = 250;     //delay from animation to black (is used twice)
const byte numberOfStrips = 6;
const byte ledsPerStrip = 10;

void turnSignal(CRGB turnColor) {
  if (stateTS != 0) {
    for (byte strip = 0; strip < numberOfStrips; strip++) {
      for byte (dot = 0; dot < ledsPerStrip; dot++) {
        leds[strip * ledsPerStrip + dot] = turnColor;
        FastLED.show();
        delay(delayTurnLedAnim);
      }
      fill_solid(leds + strip * ledsPerStrip, ledsPerStrip, CRGB::Black);
      FastLED.show();
      delay(delayTurnLedOff);
    }
  }
}

I suppose that stateTS is a global variable, as well as the array leds. The function should be called using:

turnSignal(turnColor);

where turncolor is a CRGB struct you already defined elsewhere.

But you seem to do some button monitoring inside this function: can you explain what you want to do here, because I don't understand this part of the code?

Thank you very much for your help. I will work on this in the next few days. The button monitor is due to watching which pins get signal and prioritizing them. For example, the brake light would override the tail light function. I think I will simplify the code a little and separate into 2 different hardware setups. 1 Brake and Tail Light. 2 Turn Signal and Reverse Light. I really appreciate your help with this and I enjoy building my coding skills with fun projects such as this.

Ok, keep me updated !