void setup() {
  // put your setup code here, to run once:
  volatile char *dirf,*dirk,*dira,*dirc;
  volatile char *outf,*ink,*outa,*outc;
  volatile char row,cal,x;
  volatile long i;
  *dirf=0x30;*dirk=0x107;*dira=0x21;*dirc=0x27;
  dirf=0x0F;dirk=0x00;dirf=0x0F; dirf=0x0F;
  outa=0x22;ink=0x106;outf=0x31;outc=0x28;

    while(1)
    { 
      for(row=0;row<4;row++)
      {
         *outf=1<<row;
         *outa=*ink;
         if(*ink !=0)
         {
          *outc=1<<row;
          for(i=0;i<100000;i++);
          *outc=0;
         }
         
      }

    }

}

void loop() {
  // put your main code here, to run repeatedly:

}