#define OP_DECODEMODE  9
#define OP_INTENSITY   10
#define OP_SCANLIMIT   11
#define OP_SHUTDOWN    12
#define OP_DISPLAYTEST 15

int CLK=7; 
int LOAD=6; 
int DIN=5;  

void sendData( byte address, byte data)
{ 
    byte packet[2];
    byte bitmask;
    byte i;
    packet[0]=address;
    packet[1]=data;
     
    for(i=0;i<2;i++)
    for( bitmask=0x80 ; bitmask!=0 ; bitmask=bitmask>>1 )
    {
       if(bitmask & packet[i]) digitalWrite(DIN,1); 
           else digitalWrite(DIN,0);
       
       digitalWrite(CLK, HIGH);
       digitalWrite(CLK, LOW);        
    }
    digitalWrite(LOAD,HIGH); 
    digitalWrite(LOAD,LOW);
}

void setup() {
  // put your setup code here, to run once:
    pinMode(DIN,OUTPUT);
    pinMode(CLK,OUTPUT);
    pinMode(LOAD,OUTPUT);
    digitalWrite(LOAD,LOW);


   sendData(OP_DISPLAYTEST, 0);
   sendData(OP_INTENSITY, 0);
   sendData(OP_SCANLIMIT, 7);
   sendData(OP_DECODEMODE, 0);
   sendData(OP_SHUTDOWN, 1);
   for(int i=0;i<8;i++) sendData(i+1, 0b00000000);
   
}




void loop() {
  // put your main code here, to run repeatedly:
  sendData(1,0b11000001);
   
}