void setup() {
  volatile char *dirf,*dirk,*outf,*ink, x,i;
  volatile long j;
  outf=(char*)0x31; ink=(char*)0x106;
  *dirf=0xff; *dirk=0x00;
  i=(char)0x00;
  while(1){
    x=*ink; 
    if((x & 0x01)==0x01){
    i++;
    if(i>9) i=0;
    for(j=0; j<100000; j++);
    }
    if((x & 0x02)==0x02){
    i--;
    if(i<0) i=9;
    for(j=0; j<100000; j++);
    }
    switch(i){
    case 0:*outf=0x3f;break;
    case 1:*outf=0x06;break;
    case 2:*outf=0x5b;break;
    case 3:*outf=0x4f;break;
    case 4:*outf=0x66;break;
    case 5:*outf=0x6d;break;
    case 6:*outf=0x7d;break;
    case 7:*outf=0x07;break;
    case 8:*outf=0x7f;break;
    case 9:*outf=0x6f;break;
    }
  }
}


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