求助单片机编程高手!
来源:百度知道 编辑:UC知道 时间:2024/06/01 04:36:59
你的程序有个错哦,编译不通过啊。
uchar code DB[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90}; //0~9数据
uchar a;
uint i;
uchar thbit,upbit,lowbit,hibit;
//延时子程序
void mDelay(uchar Delay)
{ uchar i;
for(;Delay>0;Delay--)
{
for(i=0;i<5;i++);
}
}
lcdcode()
{
thbit= i/1000; //提取千位
hibit= (i-thbit*1000)/100; //提取百位
upbit=(i-thbit*1000-hibit*100)/10; //提取十位
lowbit=i%10; //提取个位
for(a=0;a<70;a++) //调整a的大小可改变计数的显示速度
{
P0=DB[lowbit];
P3_0=0; //个位的位选
mDelay(5);
P3_0=1;
P0=DB[upbit];
P3_1=0; //十位的位选
mDelay(5);
P3_1=1;
P0=DB[hibit];
P3_2=0; //百位的位选
mDelay(5);