我在用Proteus进行51单片机的仿真。但是做到数码管动态显示时,数码管显示的数字是乱码。这个怎么解决
#include<reg52.h>#defineucharunsignedchar#defineuintunsignedintucharcodeshuzi[]={0x3f...
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code shuzi[]={
0x3f,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f};
sbit kaideng=P3^7;
uchar xunhuan;
void yanshi(uint xms)
{
uint x;uchar y;
for(x=xms;x>0;x--)
for(y=125;y>0;y--);
}
void main(void)
{
while(1)
{
for(xunhuan=0;xunhuan<8;xunhuan++)
{
P2=xunhuan;
P0=shuzi[xunhuan];
kaideng=1;
yanshi(10);
P0=0xff;
kaideng=0;
}
}
} 展开
#define uchar unsigned char
#define uint unsigned int
uchar code shuzi[]={
0x3f,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f};
sbit kaideng=P3^7;
uchar xunhuan;
void yanshi(uint xms)
{
uint x;uchar y;
for(x=xms;x>0;x--)
for(y=125;y>0;y--);
}
void main(void)
{
while(1)
{
for(xunhuan=0;xunhuan<8;xunhuan++)
{
P2=xunhuan;
P0=shuzi[xunhuan];
kaideng=1;
yanshi(10);
P0=0xff;
kaideng=0;
}
}
} 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询