// Jumbo 7-Segment Daisychaining Test
// (C)2011 Henning Karlsen
// http://www.rinkydinkelectronics.com/
//

int latchPin = 8;
int clockPin = 12;
int dataPin = 11;
int oePin = 9;

byte digit[] = {B00111111, B00000110, B01011011, B01001111, B01100110, B01101101, B01111101, B00000111, B01111111, B01101111, B01100011};

void setup()
{
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(oePin, OUTPUT);
  analogWrite(oePin, 128);
}

void loop()
{
  for (int numberToDisplay = 0; numberToDisplay < 100; numberToDisplay++)
  {
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, digit[numberToDisplay % 10]);  
    shiftOut(dataPin, clockPin, MSBFIRST, digit[numberToDisplay / 10]);  
    digitalWrite(latchPin, HIGH);
    delay(500);
  }
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, 0xff);  
  shiftOut(dataPin, clockPin, MSBFIRST, 0xff);  
  digitalWrite(latchPin, HIGH);
  delay(500);
  
  for (int i=128; i<256; i++)
  {
    analogWrite(oePin, i);
    delay(50);
  }
  for (int i=255; i>=128; i--)
  {
    analogWrite(oePin, i);
    delay(50);
  }
}