void setup() {
// put your setup code here, to run once:
volatile long i,j,x,y;
volatile char *dirF,*dirD,*dirA,*dirK;
dirA=0x21; dirD=0x2a; dirF=0x30;
*dirD=0x00;
*dirA=0xff;
*dirF=0xff;
volatile char *outF=0x31,*inpD,*outA,*outK;
outF=0x31;
inpD=0x29;
outA=0x22;
dirK=0x107;
*dirK=0xff;
outK=0x108;
while(1){
for(i=0;i<4;i++){
*outF=1<<i;
x=*inpD;
if(*inpD!=0){
y=1<<i;
if(y==0x01 && x==0x01){
*outK=0x06;
}
if(y==0x01 && x==0x02){
*outK=0x5b;
}
if(y==0x01 && x==0x04){
*outK=0x4f;
}
if(y==0x01 && x==0x08){
*outK=0x77;
}
if(y==0x02 && x==0x01){
*outK=0x66;
}
if(y==0x02 && x==0x02){
*outK=0x6d;
}
if(y==0x02 && x==0x04){
*outK=0x7d;
}
if(y==0x02 && x==0x08){
*outK=0x7c;
}
if(y==0x04 && x==0x01){
*outK=0x07;
}
if(y==0x04 && x==0x02){
*outK=0x7f;
}
if(y==0x04 && x==0x04){
*outK=0x6f;
}
if(y==0x04 && x==0x08){
*outK=0x39;
}
if(y==0x08 && x==0x02){
*outK=0x3f;
}
if(y==0x08 && x==0x08){
*outK=0x5e;
}
for(j=0;j<1000000;j++);
*outK=0;
}
}
}
}
void loop() {
// put your main code here, to run repeatedly:
}