单片机动态数码管显示的余晖问题

2024年11月18日 04:41
有5个网友回答
网友(1):

导致的原因一般是:选下一位的时候没有关掉上一次的数据,兆睁历族搜导致上一次的数据被带到下一位;所以一般都会在显示结束后关掉数码管,下次扫描的时候给数据就不会被黏在一起。

我早凯也经常遇到,不过遇到多了就知道解决的方法和原因,希望能帮助到你~

网友(2):

建议你把掘举悉扫描的程序放在中断中处理,而把计算b1~b6的内容放在主循环中处理。
余晖的答渗问题,我感觉是扫描过程中,你延时控制的不一致引起的。帮你改了下程判乎序,你试试
#include
#include "intrins.h"
#define uchar unsigned char
#define uint unsigned int
sbit wela=P2^7;
sbit dula=P2^6;
unsigned long base,num;
uchar count;
uchar code table1[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
uchar code table3[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf};
uchar display_buf[6];
void main()
{
base = 0;
TMOD=0x01;
TH0=(65536-9200)/256;
TL0=(65536-9200)%256; TR0=1;
EA=1;
ET0=1;
wela=0;dula=0;
while(1)
{
num = base%1000000;
display_buf[5] = (uchar)(num/100000);
num = num%100000;
display_buf[4] = (uchar)(num/10000);
num = num%10000;
display_buf[3] = (uchar)(num/1000);
num = num%1000;
display_buf[2] = (uchar)(num/100);
num = num%100;
display_buf[1] = (uchar)(num/10);
num = num%10;
display_buf[0] = num;
}
}
void inter() interrupt 1
{
uchar i;
TH0=(65536-9200)/256;
TL0=(65535-9200)%256;
count++; //每次中断按顺序扫描一个数码管
i = count%6;
base++;
P0=table1[display_buf[i]];
dula=1;
_nop_();
_nop_();
dula=0;
P0=table3[i];
wela=1;
_nop_();
_nop_();
wela=0;
}

网友(3):

while(1)
{
P0 = table1[b1]; dula = 1; dula = 0;
P0 = table3[0]; wela = 1; wela = 0; delay(10);
P0 = 255; wela = 1; wela = 0;

P0 = table1[b2]; dula = 1; dula = 0;
P0 = table3[1]; wela = 1; wela = 0; delay(10);
P0 = 255; wela = 1; wela = 0;

P0 = table1[b3]; dula = 1; dula = 0;
P0 = table3[2]; wela = 1; wela = 0; delay(10);
P0 = 255; wela = 1; wela = 0;

P0 = table1[b4]; dula = 1; dula = 0;
P0 = table3[3]; wela = 1; wela = 0; delay(10);
P0 = 255; wela = 1; wela = 0;

P0 = table1[b5]; dula = 1; dula = 0;
P0 = table3[4]; wela = 1; wela = 0; delay(10);
P0 = 255; wela = 1; wela = 0;

P0 = table1[b6]; dula = 1; dula = 0;
P0 = table3[5]; wela = 1; wela = 0; delay(10);
P0 = 255; wela = 1; wela = 0;
}

加上宴悉消隐核清即晌氏乎可。

网友(4):

显示御竖让完一位后就关闭显示就可以了。镇局还有,你这样写不觉得太臃肿吗?建议把经常出纤轿现的程序段写成一个子函数调用。

网友(5):

每次显示完之后都加上一个P0=0;消影