#include
#include
sbit ss=P1^0;
void init();
uint f;
uint i=0;
uchar code zimu[]="Speed";
void main()
{
init();
LCD1602_Init();
TR0=1;
TR1=1;
while(1)
{
uchar H[5];
H[0]=f/10000+'0';
H[1]=f%10000/1000+'0';
H[2]=f%10000%1000/100+'0';
H[3]=f%10000%1000%100/10+'0';
H[4]=f%10000%1000%100%10+'0';
LCD1602_WriteCom(0x80);LCD1602_WriteData(zimu[0]);
LCD1602_WriteCom(0x81);LCD1602_WriteData(zimu[1]);
LCD1602_WriteCom(0x82);LCD1602_WriteData(zimu[2]);
LCD1602_WriteCom(0x83);LCD1602_WriteData(zimu[3]);
LCD1602_WriteCom(0x84);LCD1602_WriteData(zimu[4]);
LCD1602_WriteCom(0x87);LCD1602_WriteData(H[0]);
LCD1602_WriteCom(0x88);LCD1602_WriteData(H[1]);
LCD1602_WriteCom(0x89);LCD1602_WriteData(H[2]);
LCD1602_WriteCom(0x8a);LCD1602_WriteData(H[3]);
LCD1602_WriteCom(0x8b);LCD1602_WriteData(H[4]);
}
}
void init()
{
TMOD=0x51; //T1¼ÆÊýÆ÷·½Ê½1 T0¼ÆʱÆ÷·½Ê½1
TH0=(65535-50000)/256;
TL0=(65535-50000)%256;
TH1=0;
TL1=0;
EA=1;
ET0=1;
ET1=1;
}
void timer() interrupt 1
{
i=i+1;
if(i==100)
{
i=0;
f=(TH1*256+TL1)/12;
TH1=0;
TL1=0;
}
TH0=(65535-50000)/256;
TL0=(65535-50000)%256;
}
为什么计不上数呢?求大神指教