#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
sbit gA=P2^2;
sbit gB=P2^3;
sbit gC=P2^4;
sbit key_s15=P3^2;
char num;
void Init()
{
EA=1;
EX0=1;
IT0=1;
}
void delay(uint z)
{
uchar x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void display()
{
uchar shi,ge;
shi=num/10;
ge=num%10;
gA=1;gB=1;gC=1;
P0=table[shi];
delay(10);
gA=0;gB=1;gC=1;
P0=table[ge];
delay(10);
}
void main()
{
while(1)
{
Init();
display();
delay(10);
}
}
void exter0() interrupt 0
{
delay(10);
if(key_s15==0)
{
num++;
if(num==16)
{
num=0;
}
}
}
|