volatile unsigned char *dirf, *dira; // 7segment and push botton
volatile unsigned char *outf, *ina;
void sevenseg(volatile char a){
switch(a){
case 1: *outf=0x06; break; //1
case 2: *outf=0x5b; break; //2
case 3: *outf=0x4f; break; //3
case 4: *outf=0x66; break; //4
case 5: *outf=0x6d; break; //5
case 6: *outf=0x7d; break; //6
case 7: *outf=0x07; break; //7
case 8: *outf=0x7f; break; //8
case 9: *outf=0x6f; break; //8
default: *outf=0x3f; break; //0
}
}
void setup() {
// put your setup code here, to run once:
dirf=0x30; dira=0x21;
*dirf=0xff; *dira=0x00;
outf=0x31; ina=0x20;
volatile unsigned char inp;
//volatile char i=0;
sevenseg(0);
while(1){
// set 2 ques 8
inp = *ina;
if(inp&0x01==0x01){
for(volatile char i=0;i<10;i++){
sevenseg(i);
for(volatile long del=0;del<500000;del++);
inp = *ina;
if((inp&0x02)==0x02){
*outf=0x00;
break;
}
if(i==9)
i=-1;
}
}
}
}
void loop() {
// put your main code here, to run repeatedly:
}