#define DELAY 300000
void setup() {
// put your setup code here, to run once:
volatile unsigned char *dirf,*dirk;
dirf=0x30; dirk=0x107;
*dirf=0xff; *dirk=0x00;
}
void loop() {
// put your main code here, to run repeatedly:
volatile unsigned char *outf,*ink,x;
volatile long i,p,q,r,s,m, sum=0;
outf=0x31; ink=0x106;
i=0;
x=*ink;
if((x&0xff)==0x01){
*outf=0x7f;
p=*outf;}
else if((x&0xff)==0x02){
*outf=0x6d;
q=*outf;}
else if ((x&0x0ff)==0x04){
*outf=0x5b;
r=*outf;}
else if ((x&0x0ff)==0x08){
*outf=0x47;
s=*outf;}
sum=p+q+r+s;
while(sum>0){
m=m+sum%10;
sum=sum/10;
}
}