#include <REGX52.H>
#include "Delay.h"
unsigned char smgTable[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void smg(unsigned char weixuan,duanxuan)
{
switch(weixuan)
{
case 1:P2_4=1;P2_3=1;P2_2=1;break;
case 2:P2_4=1;P2_3=1;P2_2=0;break;
case 3:P2_4=1;P2_3=0;P2_2=1;break;
case 4:P2_4=1;P2_3=0;P2_2=0;break;
case 5:P2_4=0;P2_3=1;P2_2=1;break;
case 6:P2_4=0;P2_3=1;P2_2=0;break;
case 7:P2_4=0;P2_3=0;P2_2=1;break;
case 8:P2_4=0;P2_3=0;P2_2=0;break;
}
P0=smgTable[duanxuan];
Delay(1);
P0=0x00;
}
void Timer0Init(void)
{
TMOD &= 0XF0;
TMOD |= 0X01;
TL0=0X66;
TH0=0XFC;
TF0=0;
TR0=0;
ET0=1;
EA=1;
PT0=0;
}
unsigned int i,j,k;
void main()
{
Timer0Init();
while(1)
{
}
}
unsigned int l;
void Timer0() interrupt 1
{
TL0=0X66;
TH0=0XFC;
while(1)
{
if(P3_1==0)
k=1;
smg(2,j);
switch(k)
{
case 1:
i++;
if(i>50)
{
i=0;j=j+1;
};
break;
}
}
}
|