Loading a long int into an array

I have an 8 position, 7-segment display driven by two, 74HC595's - the first 595 is for selecting the segments across all 8 digits, the second selects the digit. Nice big display (digits wise) with few parts.

http://www.ebay.com/itm/221500668324?_trksid=p2059210.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

I mapped it out and have it working, and can display a number stored in an array:

int latchPin = 8;     //Pin connected to ST_CP of 74HC595
int clockPin = 12;    //Pin connected to SH_CP of 74HC595
int dataPin = 11;     //Pin connected to DS of 74HC595

int x = 0;            // delay
int z =0 ; 


//  maping of segments, 192="0", 249="1", etc. thru to 9 (which is 152).
//  127 = ".", and 255 is nothing - blank.
int Digits[12]={192,249,164,176,153,146,130,248,128,152,127,255};   
int Show[8]={11,1,2,3,4,5,6,7};  //  digits to display.  The first "11" is a blank (255).
char buf [9];
long int number;

void setup() {     
  pinMode(8, OUTPUT);  
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
 // Serial.begin(9600); 
}

void loop() {


  for (int y = 1; y < 129; y <<=1) {
   digitalWrite(latchPin, LOW); // load registers
   shiftOut(dataPin, clockPin, MSBFIRST, y);
   shiftOut(dataPin, clockPin, MSBFIRST, Digits[Show[z]]);
   digitalWrite(latchPin, HIGH); //Light the display
   delay(x);
    z=z+1;
    if (z==8) z=0;  

  }
 
}

The program will display " 1234567", with the fist digit off.

I want to just make this a function that I can pass a long int to, but I can't figure out how to load a long int into an array, and suppress the leading blank digits. So if I passed "534", it would load 11,11,11,11,11,5,4,3 into the array.

Or, perhaps there is a better way of doing this without an array, manipulating the long int directly.

Any suggestions?

Thanks!

Steve

Use modulus division and a for loop to extract the actual bytes. Take 3512, for example:

3512 % 10 = 2
3512  / 10 % 10 = 1
3512 / 10 / 10 % 10= 5
3512 / 10 / 10 / 10 % 10 = 3

Once a divide by 10 results in a 0, you can start printing blanks.

Thanks! Got it counting here, with the needed refresh rate these things aren't too useful if you want your Arduino doing other things... Maybe I can get the code into a Tiny and make a backpack, but using another display (with memory and refresh) might be a better idea.

SteveL