FASTLED with WS2812B

Hello Guys,
I'm new to this forum and i'm a rookie to programming. I'm trying to build some led strips for a party. I have 300 leds splitted on 7 strips. Each strip consist on different sub-strips that i soldered togheter, the aim is to print different letters with each strip, for example, the first strip looks like this:
_
||
|
|

It's splitted in 7 sub-string so i can print "P,S,O,A,6" and so on.
Substring one takes led 0 to 6, substring 2 takes led from 7 to 11 and so on.

The problem with coding is that to do multiple letters i have to turn on different sub-string that most of the time are not in sequence. Also i have to do different animations with all the led strips. I studied a bit fastled library and i think the best way to program this is by using controllers, so that each strip is implemented as an array of controllers ( one for each substrip). i attach my first definition of strip1 and 2.

My questions are:

  • is this the best way to implement what i'm trying to do?
  • using controllers, how do i access a single led? (to do more sofisticated animations). I don't actually know how to do this (then i'll work by my own for iterations and timing);

Blink.ino (1.58 KB)

OP's code

#include <FastLED.h>

// For led chips like Neopixels, which have a data line, ground, and power, you just
// need to define DATA_PIN.  For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN


//Prima Lettera
CRGB LET1[43];
CRGB LET2[43];
CLEDController *controllerLET1[7];
CLEDController *controllerLET2[7];
uint8_t gBrightness = 100; 


void setup() { 

       //Controller 1
       controllerLET1[0]= &FastLED.addLeds<WS2812B, 2, GRB>(LET1,0,6);
       controllerLET1[1]= &FastLED.addLeds<WS2812B, 2, GRB>(LET1,7,11);
       controllerLET1[2]= &FastLED.addLeds<WS2812B, 2, GRB>(LET1,12,18);
       controllerLET1[3]= &FastLED.addLeds<WS2812B, 2, GRB>(LET1,19,25);
       controllerLET1[4]= &FastLED.addLeds<WS2812B, 2, GRB>(LET1,26,30);
       controllerLET1[5]= &FastLED.addLeds<WS2812B, 2, GRB>(LET1,31,36);
       controllerLET1[6]= &FastLED.addLeds<WS2812B, 2, GRB>(LET1,37,42);

       //Controller 2
       controllerLET2[0]= &FastLED.addLeds<WS2812B, 4, GRB>(LET2,0,6);
       controllerLET2[1]= &FastLED.addLeds<WS2812B, 4, GRB>(LET2,7,11);
       controllerLET2[2]= &FastLED.addLeds<WS2812B, 4, GRB>(LET2,12,18);
       controllerLET2[3]= &FastLED.addLeds<WS2812B, 4, GRB>(LET2,19,25);
       controllerLET2[4]= &FastLED.addLeds<WS2812B, 4, GRB>(LET2,26,30);
       controllerLET2[5]= &FastLED.addLeds<WS2812B, 4, GRB>(LET2,31,36);
       controllerLET2[6]= &FastLED.addLeds<WS2812B, 4, GRB>(LET2,37,42);
       
}

void loop() { 

   cotntrollerLET1[0]->*WHAT(?)*=CRGB::Red

}

Matt3197:
I have 300 leds splitted on 7 strips. Each strip consist ... 7 sub-string so i can print "P,S,O,A,6" and so on

So you have 49 strips in total, with 6 leds per strip? The strips are grouped into 7 digits/letters with 7 segments in each digit?

Matt3197:
i think the best way to program this is by using controllers

  • is this the best way to implement what i'm trying to do?

No, I don't think so. It would be simpler to have a single controller and link all 49 strips into a single strip. I feel that using 7 controllers and 7 Arudino pins makes the circuit and code more complicated, not simpler.

Matt3197:

  • using controllers, how do i access a single led?

Each controller will have a 6x7=42 strip (you have 43?). So to set led 4 of the 3rd segment of the 2nd letter to red you would use LET2[6*segment+4] = CRGB::RED for example. This is going to make the code very long, because of the separate array for each letter.

If using a single controller, to set led 4 of the 3rd segment of the 2nd digit/letter, you could use LED[42letter+6segment+4] = CRGB::RED

controllerLET1[0]= &FastLED.addLeds<WS2812B, 2, GRB>(LET1,0,6);

Can you explain this setup? I have so far only used this:

FastLED.addLeds<WS2811, Strip1_PIN, RGB>(Strip1, Leds*);[/quote]*

I can do that with one pin. (Per digit).

If I understand your question, you want to use fastLED to create a 7-segment display.

Here's something I threw together to test my theory. I am using a WS2811 LED string, leftover from my Christmas decorations. Since it's a string, not a strip, the LEDS are about 4-inches apart.

Here's how I arranged one string for one digit. Starting with segment-G and ending with segment B:

You can see the results on YouTube.

Here is the sketch. It's crude, but I wrote it in a couple of hours. And I learned something new in fastLED- how to use fill_solid with a subset of the LED array.

#include <FastLED.h>

FASTLED_USING_NAMESPACE

#if defined(FASTLED_VERSION) && (FASTLED_VERSION < 3001000)
#warning "Requires FastLED 3.1 or later; check github for latest code."
#endif


#define DATA_PIN D2
#define LED_TYPE WS2811
#define COLOR_ORDER RGB
#define NUM_LEDS 50

CRGB leds[NUM_LEDS];

#define BRIGHTNESS 50

#define CHR_DELAY 750       // time in ms between characters



// --------------------------- setup ---------------------------
void setup() {

  FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.setBrightness(BRIGHTNESS);

  for ( int i = 0; i < NUM_LEDS; i++) {
    leds[i] = CRGB::Green;
  }
  FastLED.show();
  FastLED.delay(500);

  FastLED.clear();
  FastLED.show();



}




// --------------------------- loop ---------------------------
void loop() {

  number0();
  FastLED.delay(CHR_DELAY);

  number1();
  FastLED.delay(CHR_DELAY);

  number2();
  FastLED.delay(CHR_DELAY);

  number3();
  FastLED.delay(CHR_DELAY);

  number4();
  FastLED.delay(CHR_DELAY);

  number5();
  FastLED.delay(CHR_DELAY);

  number6();
  FastLED.delay(CHR_DELAY);

  number7();
  FastLED.delay(CHR_DELAY);

  number8();
  FastLED.delay(CHR_DELAY);

  number9();
  FastLED.delay(CHR_DELAY);
  FastLED.delay(CHR_DELAY);

  letterA();
  FastLED.delay(CHR_DELAY);

  letterB();
  FastLED.delay(CHR_DELAY);

  letterC();
  FastLED.delay(CHR_DELAY);
  FastLED.delay(CHR_DELAY);

}

void number1() {
  FastLED.clear();
  segmentB();
  segmentC();
  FastLED.show();
}
void number2() {
  FastLED.clear();
  segmentA();
  segmentB();
  segmentD();
  segmentE();
  segmentG();
  FastLED.show();
}
void number3() {
  FastLED.clear();
  segmentA();
  segmentB();
  segmentC();
  segmentD();
  segmentG();
  FastLED.show();
}
void number4() {
  FastLED.clear();
  segmentB();
  segmentC();
  segmentF();
  segmentG();
  FastLED.show();
}
void number5() {
  FastLED.clear();
  segmentA();
  segmentC();
  segmentD();
  segmentF();
  segmentG();
  FastLED.show();
}
void number6() {
  FastLED.clear();
  segmentA();
  segmentC();
  segmentD();
  segmentE();
  segmentF();
  segmentG();
  FastLED.show();
}
void number7() {
  FastLED.clear();
  segmentA();
  segmentB();
  segmentC();
  FastLED.show();
}
void number8() {
  FastLED.clear();
  segmentA();
  segmentB();
  segmentC();
  segmentD();
  segmentE();
  segmentF();
  segmentG();
  FastLED.show();
}
void number9() {
  FastLED.clear();
  segmentA();
  segmentB();
  segmentC();
  segmentF();
  segmentG();
  FastLED.show();
}
void number0() {
  FastLED.clear();
  segmentA();
  segmentB();
  segmentC();
  segmentD();
  segmentE();
  segmentF();
  FastLED.show();
}

void letterA() {
  FastLED.clear();
  segmentA();
  segmentB();
  segmentC();
  segmentE();
  segmentF();
  segmentG();
  FastLED.show();
}
void letterB() {
  FastLED.clear();
  segmentF();
  segmentG();
  segmentC();
  segmentD();
  segmentE();
  FastLED.show();
}
void letterC() {
  FastLED.clear();
  segmentA();
  segmentE();
  segmentF();
  segmentD();
  FastLED.show();
}

void segmentA() {
  fill_solid( &(leds[20]), 4, CRGB::White );
}
void segmentB() {
  fill_solid( &(leds[24]), 4, CRGB::White );
}
void segmentC() {
  fill_solid( &(leds[4]), 4, CRGB::White );
}
void segmentD() {
  fill_solid( &(leds[8]), 4, CRGB::White );
}
void segmentE() {
  fill_solid( &(leds[12]), 4, CRGB::White );
}
void segmentF() {
  fill_solid( &(leds[16]), 4, CRGB::White );
}
void segmentG() {
  fill_solid( &(leds[0]), 4, CRGB::White );
}

Thanks everyone for the answers, you helped me a lot:

PaulRB:
No, I don't think so. It would be simpler to have a single controller and link all 49 strips into a single strip. I feel that using 7 controllers and 7 Arudino pins makes the circuit and code more complicated, not simpler.

That's true. The problem i find is that not every sub-string is the same size ( i did this in order to save the led strip because it is expensive and couldn't afford more). I will use this method where i can.

Miniflyer:
Can you explain this setup? I have so far only used this:

I found this setup in FASTLED wiki, it is used to save memory, you will find it in "controllers" section on the bottom of the page.

SteveMann:
I can do that with one pin. (Per digit).

If I understand your question, you want to use fastLED to create a 7-segment display...

That's exactly what i was trying to do (with first 2 letters, the other 5 are not 7 segment because i needed to save my strip) that use of fill solid will help me a lot!

Do you think it's smart to store arrays ( for example 1 per letter A first strip, one for letter B second strip) with every single led index to access them individually with a for cicle?
I need it because i want to make animations like painting every other led of a different color and making them move in circle.

Sorry all i could find was this:

Can you give me a link? I cant find a fastled wiki on site....

EDIT nevermind, found my answer there :slight_smile: Thanks

hi im fased with the simular problem
can we define a Font and run a data array to the pixels
i got 42x7 as so many

#include "FastLED.h"
#define NUM_STRIPS 7
#define NUM_LEDS_PER_STRIP 42
CRGB leds[NUM_STRIPS][NUM_LEDS_PER_STRIP];

void setup() {
  // put your setup code here, to run once:
  FastLED.addLeds<NEOPIXEL, 8>(leds[0], NUM_LEDS_PER_STRIP);
  FastLED.addLeds<NEOPIXEL, 2>(leds[1], NUM_LEDS_PER_STRIP);
  FastLED.addLeds<NEOPIXEL, 3>(leds[2], NUM_LEDS_PER_STRIP);
  FastLED.addLeds<NEOPIXEL, 4>(leds[3], NUM_LEDS_PER_STRIP);
  FastLED.addLeds<NEOPIXEL, 5>(leds[4], NUM_LEDS_PER_STRIP);
  FastLED.addLeds<NEOPIXEL, 6>(leds[5], NUM_LEDS_PER_STRIP);
  FastLED.addLeds<NEOPIXEL, 7>(leds[6], NUM_LEDS_PER_STRIP);
}

void loop() {
  // put your main code here, to run repeatedly:
  // This outer loop will go over each strip, one at a time
  for(int x = 0; x < NUM_STRIPS; x++) {
    // This inner loop will go over each led in the current strip, one at a time
    for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
      leds[x][i] = CRGB::Red;
      FastLED.show();
      leds[x][i] = CRGB::Black;
      delay(10);
    }
  }
}

this runs fine

what if i set up a font like

const uint8_t Font5x7[] PROGMEM = {
0x00,0x00,0x00,0x00,0x00,//  
0x00,0x00,0xfa,0x00,0x00,// !
0x00,0xe0,0x00,0xe0,0x00,// "
0x28,0xfe,0x28,0xfe,0x28,// #
0x28,0x78,0xfe,0x78,0x28,// $ BAUM
0xc4,0xc8,0x10,0x26,0x46,// %
0x6c,0x92,0xaa,0x44,0x0a,// &
0x00,0xa0,0xc0,0x00,0x00,// '
0x00,0x38,0x44,0x82,0x00,// (
0x00,0x82,0x44,0x38,0x00,// )
0x10,0x54,0x38,0x54,0x10,// *
0x10,0x10,0x7c,0x10,0x10,// +
0x00,0x0a,0x0c,0x00,0x00,// ,
0x10,0x10,0x10,0x10,0x10,// -
0x00,0x06,0x06,0x00,0x00,// .
0x04,0x08,0x10,0x20,0x40,// /
0x7c,0x8a,0x92,0xa2,0x7c,// 0
0x00,0x42,0xfe,0x02,0x00,// 1
0x42,0x86,0x8a,0x92,0x62,// 2
0x84,0x82,0xa2,0xd2,0x8c,// 3
0x18,0x28,0x48,0xfe,0x08,// 4
0xe4,0xa2,0xa2,0xa2,0x9c,// 5
0x3c,0x52,0x92,0x92,0x0c,// 6
0x80,0x8e,0x90,0xa0,0xc0,// 7
0x6c,0x92,0x92,0x92,0x6c,// 8
0x60,0x92,0x92,0x94,0x78,// 9
0x00,0x6c,0x6c,0x00,0x00,// :
0x00,0x6a,0x6c,0x00,0x00,// ;
0x00,0x10,0x28,0x44,0x82,// <
0x28,0x28,0x28,0x28,0x28,// =
0x82,0x44,0x28,0x10,0x00,// >
0x40,0x80,0x8a,0x90,0x60,// ?
0x4c,0x92,0x9e,0x82,0x7c,// @
0x7e,0x88,0x88,0x88,0x7e,// A
0xfe,0x92,0x92,0x92,0x6c,// B
0x7c,0x82,0x82,0x82,0x44,// C
0xfe,0x82,0x82,0x44,0x38,// D
0xfe,0x92,0x92,0x92,0x82,// E
0xfe,0x90,0x90,0x80,0x80,// F
0x7c,0x82,0x82,0x8a,0x4c,// G
0xfe,0x10,0x10,0x10,0xfe,// H
0x00,0x82,0xfe,0x82,0x00,// I
0x04,0x02,0x82,0xfc,0x80,// J
0xfe,0x10,0x28,0x44,0x82,// K
0xfe,0x02,0x02,0x02,0x02,// L
0xfe,0x40,0x20,0x40,0xfe,// M
0xfe,0x20,0x10,0x08,0xfe,// N
0x7c,0x82,0x82,0x82,0x7c,// O
0xfe,0x90,0x90,0x90,0x60,// P
0x7c,0x82,0x8a,0x84,0x7a,// Q
0xfe,0x90,0x98,0x94,0x62,// R
0x62,0x92,0x92,0x92,0x8c,// S
0x80,0x80,0xfe,0x80,0x80,// T
0xfc,0x02,0x02,0x02,0xfc,// U
0xf8,0x04,0x02,0x04,0xf8,// V
0xfe,0x04,0x18,0x04,0xfe,// W
0xc6,0x28,0x10,0x28,0xc6,// X
0xc0,0x20,0x1e,0x20,0xc0,// Y
0x86,0x8a,0x92,0xa2,0xc2,// Z
0x00,0x00,0xfe,0x82,0x82,// [
0x40,0x20,0x10,0x08,0x04,// (backslash)
0x82,0x82,0xfe,0x00,0x00,// ]
0x20,0x40,0x80,0x40,0x20,// ^
0x02,0x02,0x02,0x02,0x02,// _
0x00,0x80,0x40,0x20,0x00,// `
0x04,0x2a,0x2a,0x2a,0x1e,// a
0xfe,0x12,0x22,0x22,0x1c,// b
0x1c,0x22,0x22,0x22,0x04,// c
0x1c,0x22,0x22,0x12,0xfe,// d
0x1c,0x2a,0x2a,0x2a,0x18,// e
0x10,0x7e,0x90,0x80,0x40,// f
0x10,0x28,0x2a,0x2a,0x3c,// g
0xfe,0x10,0x20,0x20,0x1e,// h
0x00,0x22,0xbe,0x02,0x00,// i
0x04,0x02,0x22,0xbc,0x00,// j
0x00,0xfe,0x08,0x14,0x22,// k
0x00,0x82,0xfe,0x02,0x00,// l
0x3e,0x20,0x18,0x20,0x1e,// m
0x3e,0x10,0x20,0x20,0x1e,// n
0x1c,0x22,0x22,0x22,0x1c,// o
0x3e,0x28,0x28,0x28,0x10,// p
0x10,0x28,0x28,0x18,0x3e,// q
0x3e,0x10,0x20,0x20,0x10,// r
0x12,0x2a,0x2a,0x2a,0x04,// s
0x20,0xfc,0x22,0x02,0x04,// t
0x3c,0x02,0x02,0x04,0x3e,// u
0x38,0x04,0x02,0x04,0x38,// v
0x3c,0x02,0x0c,0x02,0x3c,// w
0x22,0x14,0x08,0x14,0x22,// x
0x30,0x0a,0x0a,0x0a,0x3c,// y
0x22,0x26,0x2a,0x32,0x22,// z
0x00,0x10,0x6c,0x82,0x00,// {
0x00,0x00,0xfe,0x00,0x00,// |
0x00,0x82,0x6c,0x10,0x00,// }
0x10,0x10,0x54,0x38,0x10,// ~
0x10,0x38,0x54,0x10,0x10,// 
};

can this be run like a scrolling text over that arrar above ?

Hello guys,
Thanks to your help i managed to finish my project and i did a little promo for the party(think it's gonna get copyrighted but it's just to show you):

Now i just have to deal with the software s**t.

Greetings to everyone who replied!

Please share the code when finished.

im also interested in your coding

sure! i will post it, but i don't have much time to think about a general code, it will work well just for my case, i will comment it to make you understand what it does

is there any reason for the Display using DGITS setup
non stripe like 7 Rows you coudt be mor flex and pattern also use all effect modes
one stripe brings you 8 letters at 15USD
or only Size matters