#include <at89x52.h>
unsigned int dem,dem1,t1,so,i,x;
unsigned int dvi,chuc,tram,BDN;
unsigned char M7D[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x9 0};
void delay(unsigned int i)
{ unsigned int j,k;
for (j=0;j<i;j++)
for(k=0;k<250;k++)
{} }
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxx
void timerngat0()interrupt 1
{ TH0=15535>>8;
TL0=15535;
BDN++;
}
void giaima()
{
dvi=dem%10;chuc=(dem/10)%10;tram=(dem/100)%10;
}
void hienthi()
{ do
{P0=M7D[dvi];P2_0=1;delay(1);P2_0=0;
P0=M7D[chuc];P2_1=1;delay(1);P2_1=0;
P0=M7D[tram];P2_2=1;delay(1);P2_2=0;
}
while(BDN<=40);
BDN=0;}
void nutnhan()
{
if(P2_4==0)
{ t1=1;x=~x;;dem=dem+15;
do
{}
while(P2_4==0);}
if(P2_3==0)
{dem=0;P3_0=0;
do
{}
while(P2_3==0);
}
}
void main()
{ TMOD=0X51;TH1=0;TL1=0;TR1=1; P1=0x00;IE=0x82;x=0;
TH0=15535>>8;
TL0=15535;TR0=1;
while(1)
{
{if(TL1==1)
P1=0x01;
if(TL1==2)
P1=0x02;
if(TL1==3)
P1=0x04;
if(TL1==4)
P1=0x08;
if(TL1==5)
{TL1=0;P1=0x00;}}
nutnhan();
if(t1==1)
{if(dem>0)
dem--;
if(dem==0)
{dem=dem;P3_0=0;}}
giaima();
hienthi();
}
}
unsigned int dem,dem1,t1,so,i,x;
unsigned int dvi,chuc,tram,BDN;
unsigned char M7D[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x9 0};
void delay(unsigned int i)
{ unsigned int j,k;
for (j=0;j<i;j++)
for(k=0;k<250;k++)
{} }
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxx
void timerngat0()interrupt 1
{ TH0=15535>>8;
TL0=15535;
BDN++;
}
void giaima()
{
dvi=dem%10;chuc=(dem/10)%10;tram=(dem/100)%10;
}
void hienthi()
{ do
{P0=M7D[dvi];P2_0=1;delay(1);P2_0=0;
P0=M7D[chuc];P2_1=1;delay(1);P2_1=0;
P0=M7D[tram];P2_2=1;delay(1);P2_2=0;
}
while(BDN<=40);
BDN=0;}
void nutnhan()
{
if(P2_4==0)
{ t1=1;x=~x;;dem=dem+15;
do
{}
while(P2_4==0);}
if(P2_3==0)
{dem=0;P3_0=0;
do
{}
while(P2_3==0);
}
}
void main()
{ TMOD=0X51;TH1=0;TL1=0;TR1=1; P1=0x00;IE=0x82;x=0;
TH0=15535>>8;
TL0=15535;TR0=1;
while(1)
{
{if(TL1==1)
P1=0x01;
if(TL1==2)
P1=0x02;
if(TL1==3)
P1=0x04;
if(TL1==4)
P1=0x08;
if(TL1==5)
{TL1=0;P1=0x00;}}
nutnhan();
if(t1==1)
{if(dem>0)
dem--;
if(dem==0)
{dem=dem;P3_0=0;}}
giaima();
hienthi();
}
}
Comment