在protues'上仿真没结果,数码管没反应程序如下:
#include<reg51.h>
sbit shiwei=P2^2
sbit gewei=P2^3// 位选
uchar code xianshi[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x5e,0x71,0x31,0x3e};//显示数组值为0~9,
uint speedlevel;
void xianshi(uint num)
{ uint i,j,m,n;
i=num%10;
j=num/10;
P0=xianshi[i];
gewei=0; //开个位数码管
delay(1);
geiwei=1;
P0=xianshi[j];
shiwei=0; //开十位数码管
delay(1);
shiwei=1; }
void delay(i)//延时函数
{
for(j=0;j<i;j++)
for(k=0;k<250;k++);
}
void main()
{
while(1)
{ speedlevel=50;
xianshi(speedlevel);
}
}
|