void setup() {
  // put your setup code here, to run once:
 volatile char *dirf,*outf;
 volatile char *dirk,*ink;
 volatile char x ;
 volatile long i=1,j;
                  dirf=0x30;
                  *dirf=0xFF;
                  outf=0x31;
                  dirk=0x107;
                  *dirk=0x00;
                  ink=0x106;
                 while(1)
                 {
                  x=*ink;
                  for(j=0;j<50000;j++);
                  if((x & 0x01)==0x01)
                  {
                    i++;
                    
                  if(i%2)
                  {
                    *outf=0x0f;
                    for(j=0;j<10000;j++);
                  }
                  else
                  {
                    *outf=0x00;
                    for(j=0;j<10000;j++);
                  }
                
                  }
                 }

                 
                  
                  
                  

}

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


}