#include<LedControl.h>
#include<binary.h>

/* lc =
DIN connects to pin 11
CLK connects to pin 13
CS connects to pin 10
*/

/* lc1 =
DIN connects to pin 2
CLK connects to pin 4
CS connects to pin 7
*/

LedControl lc=LedControl(11,13,10,16);
LedControl lc1=LedControl(2,4,7,16);

unsigned long delaytime=1000;

byte mBuf[10][8] = {
    {B00000000 ,
     B00000000 ,
     B00011000 ,    //0
     B00100100 ,
     B00100100 ,
     B00100100 ,
     B00011000 ,
     B00000000
    },
    {B00000000 ,
     B00000000 ,
     B00011000 ,    //1
     B00011100 ,
     B00011000 ,
     B00011000 ,
     B00111100 , 
     B00000000
    },
    {B00000000 ,
     B00000000 ,
     B00111100 ,    //2
     B00100000 ,
     B00111100 ,
     B00000100 ,
     B00111100 , 
     B00000000
    },
    {B00000000 ,
     B00000000 ,
     B00111100 ,    //3
     B00100000 ,
     B00111100 ,
     B00100000 ,
     B00111100 , 
     B00000000
    },
    {B00000000 ,
     B00000000 ,
     B00100100 ,    //4
     B00100100 ,
     B00111100 ,
     B00100000 ,
     B00100000 , 
     B00000000
    },
    {B00000000 ,
     B00000000 ,
     B00111100 ,    //5
     B00000100 ,
     B00111100 ,
     B00100000 ,
     B00111100 , 
     B00000000
    },
    {B00000000 ,
     B00000000 ,
     B00001100 ,    //6
     B00000100 ,
     B00111100 ,
     B00100100 ,
     B00111100 , 
     B00000000
    },
    {B00000000 ,
     B00000000 ,
     B00111100 ,    //7
     B00100000 ,
     B00010000 ,
     B00001000 ,
     B00000100 , 
     B00000000
    },
    {B00000000 ,
     B00000000 ,
     B00111100 ,    //8
     B00100100 ,
     B00111100 ,
     B00100100 ,
     B00111100 , 
     B00000000
    },
    {B00000000 ,
     B00000000 ,
     B00111100 ,    //9
     B00100100 ,
     B00111100 ,
     B00100000 ,
     B00100000 ,
     B00000000
    },
  };

void setup() {
lc.shutdown(0,false);
lc1.shutdown(0,false);
// Set brightness to a medium value
lc.setIntensity(0,8);
lc1.setIntensity(0,8);
// Clear the display
lc.clearDisplay(0);
lc1.clearDisplay(0);
}

void drawFaces(int k){
int j;
for(j=0;j<8;j++)
{
  lc.setRow(0,j,mBuf[k][j]);
  lc.setRow(1,j,mBuf[k][j]);
  lc.setRow(2,j,mBuf[k][j]);
  lc.setRow(3,j,mBuf[k][j]);
  lc.setRow(4,j,mBuf[k][j]);
  lc.setRow(5,j,mBuf[k][j]);
  lc.setRow(6,j,mBuf[k][j]);
  lc.setRow(7,j,mBuf[k][j]);
}
delay(delaytime);
}

void drawFaces1(int k){
int j;
for(j=0;j<8;j++)
{
  lc1.setRow(0,j,mBuf[k][j]);
  lc1.setRow(1,j,mBuf[k+1][j]);
  lc1.setRow(2,j,mBuf[k][j]);
  lc1.setRow(3,j,mBuf[k][j]);
  lc1.setRow(4,j,mBuf[k][j]);
  lc1.setRow(5,j,mBuf[k][j]);
  lc1.setRow(6,j,mBuf[k][j]);
  lc1.setRow(7,j,mBuf[k][j]);
}
delay(delaytime);
}
int count =0;
int cc1=1;
int temp2=count/10;
int temp1=count%10;

void loop(){
  temp1=temp2=0;
  int i=0;
  for (i=0;i<11;i++)
  drawFaces(i);
  drawFaces1(temp1);
}