Help with array!

byte pins[] = {2,3,4,5,6,7,8};

digit = 3;  // let's set pins for the digit 3

for (int i = 0; i < 7; i++) {
   digitalWrite(pins[i], digitalCount[digit][i]);
}

Personally I would pack all those bytes so you only need an array 10 byte long instead of 10x7. Maybe like this

byte digitalCount[10] = {  
//          abcdefg        
           B0000001,  // = 0
	   B1001111,  // = 1
	   B0010010,  // = 2
	   B0000110,  // = 3
	   B1001100,  // = 4
	   B0100100,  // = 5
	   B0100000,  // = 6
	   B0001111,  // = 7
	   B0000000,  // = 8
	   B0001100   // = 9
	   };

byte pins[] = {2,3,4,5,6,7,8};

digit = 3;  // let's set pins for the digit 3
byte x = digitalCount[digit];
 
for (int i = 0; i < 7; i++) {
   digitalWrite(pins[i], ((x & 1) == 1) ? HIGH : LOW);
   x >>= 1;
}

I don't have a working IDE at present to test but it should give you the idea.


Rob