关于proteus仿真数码管,动态扫描时有的数字不能显示问题!
换成其他数字就能动态扫描出来~~是不是软件本身的问题呢 ?希望有高手帮忙。小弟才一级,没法上图~请谅解 展开
2023-11-17 广告
遇到相同的问题,我是这样解决的:
1、在位选和段选打开之前先赋值
2、添加延时
以下是我的程序(显示数字19930309),仅供参考,先截图修改的部分,贴上来的代码排版不行,不知道为啥:
#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit we = P2^7;
sbit du = P2^6;
void delay(uint z)
{
uint x,y;
for(x = z; x > 0; x--)
for(y = 120; y > 0; y--);
}uchar code leddata[]={
0x3F, //"0"
0x06, //"1"
0x5B, //"2"
0x4F, //"3"
0x66, //"4"
0x6D, //"5"
0x7D, //"6"
0x07, //"7"
0x7F, //"8"
0x6F, //"9"
0x77, //"A"
0x7C, //"B"
0x39, //"C"
0x5E, //"D"
0x79, //"E"
0x71, //"F"
0x76, //"H"
0x38, //"L"
0x37, //"n"
0x3E, //"u"
0x73, //"P"
0x5C, //"o"
0x40, //"-"
0x00, //熄灭
0x00 //自定义
};
void main()
{
P0 = 0xfe;//先赋值
we = 1;//再打开位选
we = 0;P0 = leddata[1];//先赋值
du = 1;//再打开段选
du = 0;
delay(1);//设置一个较短的延时,我的是设置接近1ms
P0 = 0xfd;
we = 1;
we = 0;
P0 = leddata[9];
du = 1;
du = 0;
delay(1);P0 = 0xfb;
we = 1;
we = 0;P0 = leddata[9];
du = 1;
du = 0;
delay(1);P0 = 0xf7;
we = 1;
we = 0;P0 = leddata[3];
du = 1;
du = 0;
delay(1);P0 = 0xef;
we = 1;
we = 0;P0 = leddata[0];
du = 1;
du = 0;
delay(1);P0 = 0xdf;
we = 1;
we = 0;P0 = leddata[3];
du = 1;
du = 0;
delay(1);P0 = 0xbf;
we = 1;
we = 0;P0 = leddata[0];
du = 1;
du = 0;
delay(1);P0 = 0x7f;
we = 1;
we = 0;P0 = leddata[9];
du = 1;
du = 0;
delay(1);
}
下面是效果图: