gakko
Newbie level 6
- Joined
- Jun 6, 2013
- Messages
- 14
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,363
I have do a adder have three button
it is reset, up, down respectively
It have some display error and plz help me
it is reset, up, down respectively
It have some display error and plz help me
Code:
sbit reset = P1^4;
sbit up = P1^5;
sbit down = P1^6;
unsigned char CA_Digits[] = {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90, 0x88, 0x83, 0xC6, 0xA1, 0x86, 0x8E};
unsigned int count = 0;
unsigned int a, b, c, d;
P0 = 0x00;
P1 = 0xFF;
P2 = 0x00;
while(1){
if(P1^4==0);
count = 0;
if(P1^5== 0);
count = count+1;
if(P1^6 == 0);
count = count-1;
if(count <= 16){
a = count;
P2 = 0xFE;
P0 = CA_Digits[a];
delay();
P2 = 0xFC;
P0 = CA_Digits[0];
delay();
P2 = 0xF8;
P0 = CA_Digits[0];
delay();
P2 = 0xF0;
P0 = CA_Digits[0];
delay();
}
if((count > 16) && (count <= 255)){
a = count/16;
b = count%16;
P2 = 0xFE;
P0 = CA_Digits[b];
delay();
P2 = 0xFC;
P0 = CA_Digits[a];
delay();
P2 = 0xF8;
P0 = CA_Digits[0];
delay();
P2 = 0xF0;
P0 = CA_Digits[0];
delay();
}
if((count > 255) && (count <= 4095)){
a = count/255;
b = (count/16)%16;
c = count%16;
P2 = 0xFE;
P0 = CA_Digits[c];
delay();
P2 = 0xFC;
P0 = CA_Digits[b];
delay();
P2 = 0xF8;
P0 = CA_Digits[a];
delay();
P2 = 0xF0;
P0 = CA_Digits[0];
delay();
}
if((count > 4095) && (count <= 65535)){
a = count/4095;
b = (count/255)%16;
c = (count/16)%16;
d = count%16;
P2 = 0xFE;
P0 = CA_Digits[d];
delay();
P2 = 0xFC;
P0 = CA_Digits[c];
delay();
P2 = 0xF8;
P0 = CA_Digits[b];
delay();
P2 = 0xF0;
P0 = CA_Digits[a];
delay();
}
}
Last edited: