3x seven segment w/ shift register code

Hi all,
I've built three seven segment displays each driven by a 74hc164 shift register. I've tested each pair separately with this code:

#define data 2
#define clock 3



byte zero  = B01111110;
byte one   = B00000110;
byte two   = B11011010;
byte three = B11010110;
byte four  = B10100110;
byte five  = B11110100;
byte six   = B11111100;
byte seven = B01000110;
byte eight = B11111110;
byte nine  = B11110110;



void setup()
{
  pinMode(clock, OUTPUT); // make the clock pin an output
  pinMode(data , OUTPUT); // make the data pin an output3
}

void loop()
{
    shiftOut(data, clock, LSBFIRST, zero);
    delay(500);
    shiftOut(data, clock, LSBFIRST, one);
    delay(500);
    shiftOut(data, clock, LSBFIRST, two);
    delay(500);
    shiftOut(data, clock, LSBFIRST, three);
    delay(500);
    shiftOut(data, clock, LSBFIRST, four);
    delay(500);
    shiftOut(data, clock, LSBFIRST, five);
    delay(500);
    shiftOut(data, clock, LSBFIRST, six);
    delay(500);
    shiftOut(data, clock, LSBFIRST, seven);
    delay(500);
    shiftOut(data, clock, LSBFIRST, eight);
    delay(500);
    shiftOut(data, clock, LSBFIRST, nine);
    delay(500);
}

And they work perfectly.
Now I've written this code to condense all that and eventually operate the three pairs together.
When I try to compile the code it gives me the error "expected unqualified ID before '[' token.

#define data 2;
#define clock 3;


void setup() {
  
  
  int mE=-1;
  // use binary notation to discribe our number layout
  byte [0] = B00000001;
  byte [1] = B11000111;
  byte [2] = B00100010;
  byte [3] = B10000010;
  byte [4] = B11000100;
  byte [5] = B10001000;
  byte [6] = B00001000;
  byte [7] = B11000011;
  byte [8] = B00000000;
  byte [9] = B10000000;

  pinMode(clock, OUTPUT); // make the clock pin an output
  pinMode(data , OUTPUT); // make the data pin an output3
}

void loop(){
  
  for(int mE = -1; mE<11; mE++) {
     shiftOut(data, clock, LSBFIRST, mE);
     delay(500);
     if(mE == 10){
         int(mE) = -1;
     }
  }
}

So to summarise I'm asking for improvements upon my code. Any help is appreciated thank you.
BTW I'm new to C so please excuse the code. :~

The compiling error is a result of the next 2 lines
First example :

#define data 2
#define clock 3

Second :

#define data 2;
#define clock 3;

Next problem, you want to use an array in your second example, but you don't name it.
I haven't tested it, here's an example of how it could work.

#define data 2
#define clock 3

byte number[10] = {B00000001, B11000111, B00100010, B10000010, B11000100, B10001000, B00001000, B11000011, B00000000, B10000000 };

void setup() {
  pinMode(clock, OUTPUT); // make the clock pin an output
  pinMode(data , OUTPUT); // make the data pin an output3
}

void loop(){
  for(int mE = 0; mE<10; mE++) {
     shiftOut(data, clock, LSBFIRST, number[mE]);
     delay(500);
  }
}

Thanks for your reply,
I've incorporated the array into my code and it works great! :slight_smile:
Now I've added the tens and hundreds digits but the hundreds doesn't work. I find it strange since it's basically the same as the tens(which does work)
Here is my code:

#define datae 6
#define clocke 7
#define data 4
#define clock 5
#define dat 2
#define cloc 3


byte number[10] = {B00000001, B11000111, B00100010, B10000010, B11000100, B10001000, B00001000, B11000011, B00000000, B10000000 };

int tens = 0;
int hund = 0;

void setup() {
  pinMode(clock, OUTPUT); // make the clock pin an output
  pinMode(data , OUTPUT); // make the data pin an output3
  pinMode(clocke, OUTPUT);
  pinMode(datae, OUTPUT);
}

void loop(){
  for(int mE = 0; mE<10; mE++) {
     shiftOut(datae, clocke, LSBFIRST, number[mE]);
     delay(100);
     if(mE == 9) {
       tens = tens++;
       mE = 0;
       shiftOut(data, clock, LSBFIRST, number[tens]);
     
       if(tens == 9) {
         hund = hund++;
         tens = 0;
         shiftOut(dat, cloc, LSBFIRST, number[hund]);
       }
     }
  }
}

Ohhh, I see the problem. Forgot to make the pins output. :roll_eyes:

Hi,

Do you know that you can "daisy-chain" all 3 shift registers using the same two Arduino outputs?

You would connect the same Arduino output to the clock input of all 3 shift registers. You would connect an arduino output to the data input of the first sr. Then connect the Q7 output of the first sr to the data input of the second register (as well as the segment led) and the Q7 output of the second sr to the data input of the third sr.

Paul