Create array out of digitalWrite

Hi everyone!

Today I need youre help with a little Arduino counter. I have a 4 digit 7 segment display and I would like that it change number during a for loop. The fact is that I have the program that change the segments but I would like to insert it into an array... I'll make you an example (the pin numbers are just for example)

numbers[0][] = {
    digitalWrite(1, HIGH),
    digitalWrite(2, HIGH),
    ....
}
numbers[1][] = {
    digitalWrite(1, LOW),
    digitalWrite(2, HIGH),
    ....
}
numbers[2][] = {
    digitalWrite(1, HIGH),
    digitalWrite(2, LOW),
    ....
}

I hope that you can understand me :sweat_smile:
Do you have any clue?
Thank you in advance

You cannot store code in an array, to be executed. However you can store 1 and 0 bits, to be output by digitalWrite statements.

Most people use lookup tables to display numbers and other characters on LEDs.

Here is an example: https://create.arduino.cc/projecthub/aboda243/get-started-with-seven-segment-c73200

Thank you so much! You were so quick to answer!! Thank you! :grin:

Here is an example. You will have to insert the appropriate HIGH and LOW values for the segments.

byte numbers[10][7] = {{LOW, HIGH, LOW, HIGH, LOW, LOW, LOW},
                      {LOW, HIGH, LOW, HIGH, LOW, LOW, LOW},
                      {LOW, HIGH, LOW, HIGH, LOW, LOW, LOW},
                      {LOW, HIGH, LOW, HIGH, LOW, LOW, LOW},
                      {LOW, HIGH, LOW, HIGH, LOW, LOW, LOW},
                      {LOW, HIGH, LOW, HIGH, LOW, LOW, LOW},
                      {LOW, HIGH, LOW, HIGH, LOW, LOW, LOW},
                      {LOW, HIGH, LOW, HIGH, LOW, LOW, LOW},
                      {LOW, HIGH, LOW, HIGH, LOW, LOW, LOW},
                      {LOW, HIGH, LOW, HIGH, LOW, LOW, LOW}};
byte segmentPin[7] = {2, 3, 4, 5, 6, 7, 8};

void displayNumber(int num)
{
  for (int i = 0; i < 7; i++) digitalWrite(segmentPin[i], numbers[num][i]);
}

void setup() {
    
}

void loop() {
    
}