How to call in second matrix of leds

Hey guys,

I hope someone can help me.

I'm using WS2811 Led string,
i've build 2 times matrix of 5x3, in the following order.
Now i've succeed in making the numbers 0 till 9 for the first matrix, how can i controll the second matrix?
without touching (changing) the first one?
0-1-2 27-28-29
5-4-3 26-25-24
6-7-8 21-22-23
11-10-9 20-19-18
12-13-14 15-16-17

This code is for the 0 in the first matrix:
long getal0[] =
{
0x008000, 0x008000, 0x008000,
0x008000, 0x000000, 0x008000,
0x008000, 0x000000, 0x008000,
0x008000, 0x000000, 0x008000,
0x008000, 0x008000, 0x008000
};

Please post a complete sketch illustrating what you have got working so far

Please do reply #1,
The general idea is that you write data to the buffer (this is done in different ways depending on the library you use)

This code is for the 0 in the first matrix:

in 50% green color.
If you copy the number data to the buffer in one go, you will just have to make sure that you copy it to the area where it is sent to the second half of the leds.
Again we need to see what how you've done it, before we can explain the easiest way to do this.

I would create indicies for the matrices to convert:

0-1-2 27-28-29
5-4-3 26-25-24
6-7-8 21-22-23
11-10-9 20-19-18
12-13-14 15-16-17

into:

0-1-2 15-16-17
3-4-5 18-19-20
... ...

Like this:

MATRIX_SIZE = 15

MATRIX1[MATRIX_SIZE] = {
  0, 1, 2,
  5, 4, 3,
  6, 7, 8,
  11, 10, 9,
  12, 13, 14
};

MATRIX2[MATRIX_SIZE] = {fill me out};

...

strip.setPixelColor(index < MATRIX_SIZE ? MATRIX1[index] : MATRIX2[index-MATRIX_SIZE], color);

That would make coding for the matrices much easier.

[code]
#include "FastLED.h"

//Aantal Leds
#define NUM_LEDS 30

//Pin gebruikt voor de data
#define DATA_PIN 2

//Array of Leds
CRGB leds[NUM_LEDS];

//Codes voor getallenreeks A

long AA[] = 
{
  0x000000, 0x008000, 0x000000,
  0x000000, 0x008000, 0x000000,
  0x000000, 0x008000, 0x000000,
  0x000000, 0x008000, 0x000000,
  0x000000, 0x008000, 0x000000
};

long AB[] = 
{
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x000000,
  0x008000, 0x008000, 0x008000,
  0x000000, 0x000000, 0x008000,
  0x008000, 0x008000, 0x008000
};

long AC[] = 
{
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x000000,
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x000000,
  0x008000, 0x008000, 0x008000
};

long AD[] = 
{
  0x008000, 0x000000, 0x008000,
  0x008000, 0x000000, 0x008000,
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x000000,
  0x000000, 0x000000, 0x008000
};

long AE[] = 
{
  0x008000, 0x008000, 0x008000,
  0x000000, 0x000000, 0x008000,
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x000000,
  0x008000, 0x008000, 0x008000
};

long AF[] = 
{
  0x008000, 0x008000, 0x008000,
  0x000000, 0x000000, 0x008000,
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x008000,
  0x008000, 0x008000, 0x008000
};

long AG[] = 
{
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x000000,
  0x000000, 0x000000, 0x008000,
  0x008000, 0x000000, 0x000000,
  0x000000, 0x000000, 0x008000
};

long AH[] = 
{
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x008000,
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x008000,
  0x008000, 0x008000, 0x008000
};

long AI[] = 
{
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x008000,
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x000000,
  0x008000, 0x008000, 0x008000
};

long AZ[] = 
{
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x008000,
  0x008000, 0x000000, 0x008000,
  0x008000, 0x000000, 0x008000,
  0x008000, 0x008000, 0x008000
};

//Codes voor getallenreeks B

long BA[] = 
{
  0x000000, 0x008000, 0x000000,
  0x000000, 0x008000, 0x000000,
  0x000000, 0x008000, 0x000000,
  0x000000, 0x008000, 0x000000,
  0x000000, 0x008000, 0x000000
};

long BB[] = 
{
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x000000,
  0x008000, 0x008000, 0x008000,
  0x000000, 0x000000, 0x008000,
  0x008000, 0x008000, 0x008000
};

long BC[] = 
{
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x000000,
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x000000,
  0x008000, 0x008000, 0x008000
};

long BD[] = 
{
  0x008000, 0x000000, 0x008000,
  0x008000, 0x000000, 0x008000,
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x000000,
  0x000000, 0x000000, 0x008000
};

long BE[] = 
{
  0x008000, 0x008000, 0x008000,
  0x000000, 0x000000, 0x008000,
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x000000,
  0x008000, 0x008000, 0x008000
};

long BF[] = 
{
  0x008000, 0x008000, 0x008000,
  0x000000, 0x000000, 0x008000,
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x008000,
  0x008000, 0x008000, 0x008000
};

long BG[] = 
{
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x000000,
  0x000000, 0x000000, 0x008000,
  0x008000, 0x000000, 0x000000,
  0x000000, 0x000000, 0x008000
};

long BH[] = 
{
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x008000,
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x008000,
  0x008000, 0x008000, 0x008000
};

long BI[] = 
{
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x008000,
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x000000,
  0x008000, 0x008000, 0x008000
};

long BZ[] = 
{
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x008000,
  0x008000, 0x000000, 0x008000,
  0x008000, 0x000000, 0x008000,
  0x008000, 0x008000, 0x008000
};

//B1 = A1+15;
//B2 = A2+15;


void setup() {
 FastLED.addLeds<NEOPIXEL,DATA_PIN>(leds, NUM_LEDS);
 

}

void loop() {

///////////////getallen in A////////////////
  
FastLED.clear();
for(int i = 0; i < 15; i++) {
    leds[i] = AA[i];
}
FastLED.setBrightness (75);
FastLED.show();
delay(1000);

for(int i = 0; i < 15; i++) {
    leds[i] = AB[i];
}

FastLED.setBrightness (75);
FastLED.show();
delay(1000);

for(int i = 0; i < 15; i++) {
    leds[i] = AC[i];
}
FastLED.setBrightness (75);
FastLED.show();
delay(1000);

for(int i = 0; i < 15; i++) {
    leds[i] = AD[i];
}
FastLED.setBrightness (75);
FastLED.show();
delay(1000);

for(int i = 0; i < 15; i++) {
    leds[i] = AE[i];
}
    
for(int i = 15; i < NUM_LEDS; i++) {
    leds[i] = BA[i];
}
FastLED.setBrightness (75);
FastLED.show();
delay(1000);

for(int i = 0; i < 15; i++) {
    leds[i] = AF[i];
}
FastLED.setBrightness (75);
FastLED.show();
delay(1000);

for(int i = 0; i < 15; i++) {
    leds[i] = AG[i];
}
FastLED.setBrightness (75);
FastLED.show();
delay(1000);

for(int i = 0; i < 15; i++) {
    leds[i] = AH[i];
}
FastLED.setBrightness (75);
FastLED.show();
delay(1000);

for(int i = 0; i < 15; i++) {
    leds[i] = AI[i];
}
FastLED.setBrightness (75);
FastLED.show();
delay(1000);


for(int i = 0; i < 15; i++) {
    leds[i] = AZ[i];
}
FastLED.setBrightness (75);
FastLED.show();
delay(1000);








///////////////Getallen in B////////////

FastLED.clear();
for(int i = 15; i < NUM_LEDS; i++) {
    leds[i] = BA[i];
}
FastLED.setBrightness (75);
FastLED.show();
delay(1000);

for(int i = 15; i < NUM_LEDS; i++) {
    leds[i] = BB[i];
}

FastLED.setBrightness (75);
FastLED.show();
delay(1000);

for(int i = 15; i < NUM_LEDS; i++) {
    leds[i] = BC[i];
}
FastLED.setBrightness (75);
FastLED.show();
delay(1000);

for(int i = 15; i < NUM_LEDS; i++) {
    leds[i] = BD[i];
}
FastLED.setBrightness (75);
FastLED.show();
delay(1000);

for(int i = 15; i < NUM_LEDS; i++) {
    leds[i] = BE[i];
}
FastLED.setBrightness (75);
FastLED.show();
delay(1000);

for(int i = 15; i < NUM_LEDS; i++) {
    leds[i] = BF[i];
}
FastLED.setBrightness (75);
FastLED.show();
delay(1000);

for(int i = 15; i < NUM_LEDS; i++) {
    leds[i] = BG[i];
}
FastLED.setBrightness (75);
FastLED.show();
delay(1000);

for(int i = 15; i < NUM_LEDS; i++) {
    leds[i] = BH[i];
}
FastLED.setBrightness (75);
FastLED.show();
delay(1000);

for(int i = 15; i < NUM_LEDS; i++) {
    leds[i] = BI[i];
}
FastLED.setBrightness (75);
FastLED.show();
delay(1000);


for(int i = 15; i < NUM_LEDS; i++) {
    leds[i] = BZ[i];
}
FastLED.setBrightness (75);
FastLED.show();
delay(1000);

}


// Aangeven 501 = AE and BZ and CA
// Aangeven 500 = AE and BA and CA
// Aangeven 499 = AI and BZ and CZ
// Etc.

// Code schrijven 501 = start minus invoer = Getal reeksen

[/code]
Link to image:

The red line is the way the leds are inserted,
So the coding of the leds is what i said im my first post.
I can control my leds, and even the first 15 / second 15 and so on.
But my question:
It will be a scoreboard,
How can i code it to say first number is first 15 leds,
second nummer second 15 leds.
And then how can is say when the score is 450 i Need AD / BD
Where A is the first and B the second.

Well first off all, change your your numbers into a 2 dimensional array rather than a bunch 1 dimensional array. This doesn't answer your question but you really should.
Here :

for(int i = 0; i < 15; i++) {
    leds[i] = AA[i];
}

you write the data to the buffer, now if you change it to

for(int i = 0; i < 15; i++) {
    leds[i+15] = AA[i];
}

you write the same data to the second part of the buffer.
and then you call

FastLED.setBrightness (75);
FastLED.show();

and send the buffer data. Keep in mind that sending the data does not clear the buffer.
So after you create a 2 dimensional array, you can write to the buffer really easily.

CRGB digit[][] = {  // i think you can declare and assign a CRGB like this otherwise use uint32_t
{
  0x008000, 0x000000, 0x008000,
  0x008000, 0x000000, 0x008000,
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x000000,
  0x000000, 0x000000, 0x008000
},
{
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x000000,
  0x008000, 0x008000, 0x008000,
  0x008000, 0x000000, 0x000000,
  0x008000, 0x008000, 0x008000
};

In the end as i see now all you digits could actually be held by a single 16-bit value, and then be created on the fly by setting the color value for the writing (and even the background)
Anyway, now you can write to the buffer using :

for (int j = 0; j < 2; j++) {
  for(int i = 0; i < 15; i++) {
    leds[i + 15 * j ] = digit[dignr][i];
  }
}

where digitnr is the number you want to display.
I started think about progmem, but as i said before then i realized that the digits are in fact monochrome, so you could store them in a 16-bit variable per digit.

Deva_Rishi:
where digitnr is the number you want to display.
I started think about progmem, but as i said before then i realized that the digits are in fact monochrome, so you could store them in a 16-bit variable per digit.

Now i'm using this for the digits:

int Een [5] [3] ={
  {0,1,0},
  {0,1,0},
  {0,1,0},
  {0,1,0},
  {0,1,0},
};

And this to display:

  for (int i=0; i<3;i++){
    for (int j=0;j<5;j++){
    if (Check_Pixel_In_Digit(Current_Digit,i,j)==1) leds[(i)*5+j]=CRGB(0x008000);
    if (Check_Pixel_In_Digit(Current_Digit,i,j)==0) leds[(i)*5+j]=CRGB(0x000000);
    }
  }

When i'm moving to the second 15 leds i just can change the i=0 and j=0 to 15 right?
Only the thing is.. because i'm using ws2811 leds the matrix isnt connected as a matrix is.
So no connection in vertical direction..
How can i solve this?

You are using 15 int's (30 bytes) of memory to store something that could be stored in 2 bytes / 15 bits - that's a waste of space. You could modify your for loop to have a "current matrix":

#define MATRIX_SIZE 15

byte current_matrix = 0;

for (int i=0; i<3;i++) {
  for (int j=0;j<5;j++) {
    int index = (current_matrix*MATRIX_SIZE) + (i*5) + j;
    if (Check_Pixel_In_Digit(Current_Digit,i,j)==1) leds[index] = CRGB(0x008000);
    else leds[index] = CRGB(0x000000);
  }
}

Setting "current_matrix=1" will set LED's in the second matrix and so on..

Danois90:
Setting "current_matrix=1" will set LED's in the second matrix and so on..

Thanks, that's a better way.
But when i'm using int [] [] it doesnt work.
For the digit One it will display:

Looks like the math is wrong, "(i5) + j" should be "(j3) + i".

I am fully with Danois90 on this. Of course you could represent you digit like this :

int Een [5] [3] ={
  {0,1,0},
  {0,1,0},
  {0,1,0},
  {0,1,0},
  {0,1,0},
};

, but like this uint16_t Een = 0b0100100100100100Now to help you along a little more, say we call the array that holds the numbers 'Getal'uint16_t Getal[10] = { the population, etc.};
I recommend putting the 0 at the beginning of the array, it will make a lot more sense.
Then a function like this :

void PutDigitInBuffer(uint8_t loc, uint8_t digit, CRGB color) {
  if ((digit > 9) || (loc * 15 > NUM_LEDS)) return;  // error check for reading and writing to the array
  uint16_t matrix = Getal[digit];
  uint8_t i = 16;
  while (i) {
    i--; // decrease the index
    matrix = matrix >> 1; // shiftout the matrix. (first bit is a dummy)
    if (matrix & 1)  buf[loc * 15 + i] = color; // compare the bit
    else buf[loc * 15 + i] = 0;
  }
}

can be used to fill the ledstrip buffer

Deva_Rishi:
can be used to fill the ledstrip buffer

So now i've this:

#define <FastLED.h>

#define NUM_LEDS 30

#define DATA_PIN 2

CRGB leds[NUM_LEDS];

uint16_t One = 010010010010010
uint16_t Two = 111100111001111
uint16_t Three = 111100111100111
uint16_t Four = 101101111100001
uint16_t Five =111001111100111
uint16_t Six = 111001111101111
uint16_t Seven = 111100001100001
uint16_t Eight = 111101111101111
uint16_t Nine = 111101111100111
uint16_t Zero = 111101101101111

Better way to do this?

Now to help you along a little more, say we call the array that holds the numbers 'Getal'

This i dont understand.
What you mean.
Let's go back to the beginning.

just say first 15 leds are column A, next 15 B etc
How can i display
501
So A will display 5 etc..

The last posted code is broken, huge integers and no ";" line termination. Binary numbers are alway prefixed with "0b" as suggested in #10.

Danois90:
The last posted code is broken, huge integers and no ";" line termination. Binary numbers are alway prefixed with "0b" as suggested in #10.

Okay i dit that all the way.
But how to show them..

0-1-2 27-28-29
5-4-3 26-25-24
6-7-8 21-22-23
11-10-9 20-19-18
12-13-14 15-16-17

Oh dear i hadn't even seen that ! oh man you put the whole thing zig-zag ! don't you have a soldering iron ? ok, we will have to add a map function. I am sorry about that. Well ok, i think you should have just put them in sequencially, but let's just create an array that holds the locationuint8_t ledseq[] = {0, 1, 2, 5, 4, 3, 6, 7, 8, 11, 10, 9, 12, 13, 14, 27, 28, 29, 26, 25, 24, 21, 22, 23, 20, 19, 18, 15, 16, 17};
then instead of

if (matrix & 1)  buf[loc * 15 + i] = color; // compare the bit
    else buf[loc * 15 + i] = 0;

do :

if (matrix & 1)  buf[ledseq[loc * 15 + i]] = color; // compare the bit
    else buf[ledseq[loc * 15 + i]] = 0;

That should work. but please check.
I was going from the point of view that the lights were printed

0, 1, 2     15, 16, 17
3, 4, 5     18,19,20
6, 7, 8     21,22,23
9,10,11    24,25,26
12,13,14  27,28,29

Anyway, how to call the function. Say you have populated your bitmap array (cause that's what it is) Getal[] in such a way that the first number is 0 = { 0b1111011011011110, and you populate the characters so that bit 2 represents location 14, and bit 16 represents location 0. (as i have written them)
Now you call say i want to display the number 15, that would be the

PutDigitInBuffer(0, 1, 0x008000); // colom 0, digit 1
PutDigitInBuffer(1, 5, 0x008000); // colom 0, digit 5
// color as you like

And then call show();
Sorry i didn't see the mapping that confuses things a little, Anyway you should not create different bitmaps for each colom, you should create 1 universal bitmap (in a logical format) and then map to the matrix. Probably 'matrix' is the best name for that mapping array, but i had used that name already.

Deva_Rishi:
Sorry i didn't see the mapping that confuses things a little, Anyway you should not create different bitmaps for each colom, you should create 1 universal bitmap (in a logical format) and then map to the matrix. Probably 'matrix' is the best name for that mapping array, but i had used that name already.

This is the way the leds are inserted: i will change them so every colom will me the same.
like 1-2-3
6-5-4
etc

Now i have the following code:

#include <FastLED.h>

#define NUM_LEDS 30
#define MATRIX_SIZE 15
#define Current_Digit = 0
byte current_matrix = 0;



#define DATA_PIN 2

CRGB leds[NUM_LEDS];

uint8_t ledseq[] = {0, 1, 2, 5, 4, 3, 6, 7, 8, 11, 10, 9, 12, 13, 14};

uint16_t One = 0b010010010010010;
uint16_t Two = 0b111100111001111;
uint16_t Three = 0b111100111100111;
uint16_t Four = 0b101101111100001;
uint16_t Five = 0b111001111100111;
uint16_t Six = 0b111001111101111;
uint16_t Seven = 0b111100001100001;
uint16_t Eight = 0b111101111101111;
uint16_t Nine = 0b111101111100111;
uint16_t Zero = 0b111101101101111;

//uint16_t Getal[10] = { the population, etc}

void setup() {

for (int i=0; i<3; i++) {
  for (int j=0; j<5; j++) {
    int index = (current_matrix*MATRIX_SIZE) + (i+5) + j;
    if (Check_Pixel_In_Digit(Current_Digit,i,j)==1) leds[index] = CRGB(0x008000);
    else leds[index] = CRGB(0x000000);
  }
  }
}
void PutDigitInBuffer (uint8_t loc, uint8_t digit, CRGB color) {
  if ((digit > 9 || (loc * 15 > NUM_LEDS)) return; // error check for reading and writing to array
  uint16_t matrix = Getal[digit];
  uint8_t i = 16;
  while (i) {
    i--; // decrease the index
    matrix = matrix >> 1; // shiftout the matrix
    if (matrix & 1) buf[ledseq[loc * 15 + i]] = color;
    else buf[ledseq[loc * 15 + i]] = 0;
  }
}

  }
  
}
void loop() {
  
}

Get some errors
Digit_V1:34:47: error: 'Check_Pixel_In_Digit' was not declared in this scope
if (Check_Pixel_In_Digit(Current_Digit,i,j)==1) leds[index] = CRGB(0x008000);
^
Digit_V1:41:21: error: 'Getal' was not declared in this scope
uint16_t matrix = Getal[digit];
^
Digit_V1:46:21: error: 'buf' was not declared in this scope
if (matrix & 1) buf[ledseq[loc * 15 + i]] = color;
^
Digit_V1:47:10: error: 'buf' was not declared in this scope
else buf[ledseq[loc * 15 + i]] = 0;
^
exit status 1
'Check_Pixel_In_Digit' was not declared in this scope

So how to declare:
Check_Pixel_In_Digit
Getal
buf

#define Current_Digit = 0
Either #define Current_Digit as 0 or declare a variable named Current_Digit and give it a value of 0. As it is it is a mixture of both

Where exactly is the Check_Pixel_In_Digit() function declared ? Certainly not in the code that you posted. Similarly, where is the buf array declared ?

tempexmonster:
This is the way the leds are inserted: i will change them so every colom will me the same.

there is no need with the mapping array.

uint16_t One = 0b010010010010010;
uint16_t Two = 0b111100111001111;
uint16_t Three = 0b111100111100111;
uint16_t Four = 0b101101111100001;
uint16_t Five = 0b111001111100111;
uint16_t Six = 0b111001111101111;
uint16_t Seven = 0b111100001100001;
uint16_t Eight = 0b111101111101111;
uint16_t Nine = 0b111101111100111;
uint16_t Zero = 0b111101101101111;

please just change this into an array and just simply make them all left to right top to bottom and not use the last bit (so that should be 0)

uint16_t Getal[] = {0b1111011011011110, 0b0100100100100100,  0b1110011111001110, 0b1110011110011110, 0b1011011110010010, 0b1111001110011110, 0b1111001111011110, 0b1110010010010010, 0b1111011111011110, 0b1111011110011110};

now that declares the bitmap for the digits 0-9 as Getal[ 0-9 ]
buf was supposed to be your led buffer, i see now it is called 'leds' just change all instances of 'buf' to 'leds' (or vice versa.)
Check_Pixel_In_Digit doesn't exist (i never wrote that function !)
You can now just simply do

PutDigitInBuffer(0,5,0x008000);

To put digit '5' in the buffer in the first matrix. (in 50% green)
Please note that should not reduce the size of the ledseq array without changing the function PutDigitInBuffer(). It expects an array with 30 entries, and i put all the values in there in exactly the way you had put the leds, if you've changed them since you will have to modify the array accordingly.

Just in case let me post a full sketch that compiles (there was a small error in what i posted before) So you don't get to frustrated. This should work with how you had the LED's initially (in you OP)

#include <FastLED.h>

#define NUM_LEDS 30
#define MATRIX_SIZE 15
#define DATA_PIN 2

CRGB leds[NUM_LEDS];

uint8_t ledseq[] = {0, 1, 2, 5, 4, 3, 6, 7, 8, 11, 10, 9, 12, 13, 14, 27, 28, 29, 26, 25, 24, 21, 22, 23, 20, 19, 18, 15, 16, 17};

uint16_t Getal[] = {0b1111011011011110, 0b0100100100100100, 0b1110011111001110, 
                    0b1110011110011110, 0b1011011110010010, 0b1111001110011110, 
                    0b1111001111011110, 0b1110010010010010, 0b1111011111011110, 
                    0b1111011110011110};


void setup() {
  
  PutDigitInBuffer(0, 5, 0x008000);
  PutDigitInBuffer(1, 7, 0x008000);

}

void loop() {
 
}

void PutDigitInBuffer (uint8_t loc, uint8_t digit, CRGB color) {
  if ((digit > 9) || (loc * 15 > NUM_LEDS)) return; // error check for reading and writing to array
  uint16_t matrix = Getal[digit];
  uint8_t i = 16;
  while (i) {
    i--; // decrease the index
    matrix = matrix >> 1; // shiftout the matrix
    if (matrix & 1) leds[ledseq[loc * 15 + i]] = color;
    else leds[ledseq[loc * 15 + i]] = 0;
  }
}