单片机LCD显示163这个数字,但是前面两位都有比较弱的余晖(眼睛能识别出)
时间:10-02
整理:3721RD
点击:
图片是显示的结果。第一位的1和第二位的6都有点不正常,有亮度比较暗的其他数字显示。第三位的3就正常,没有问题。请问要怎样改才能正常显示?
程序如下,我应该怎么改?
#include<reg52.h>
sbit dula=P2^6;
sbit wela=P2^7;
unsigned char code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
unsigned char code tablewe[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf};
unsigned char temp,bai,shi,ge;
void display(unsigned char bai,shi,ge);
void delay(unsigned char a);
void main()
{
temp=163;
bai=temp/100;
shi=temp%100/10;
ge=temp%10;
dula=0;
wela=0;
while(1)
{
display(bai,shi,ge);
};
}
void display(unsigned char bai,shi,ge)
{
P0=table[bai];
dula=1;
dula=0;
P0=0xff;
P0=tablewe[0];
wela=1;
wela=0;
delay(5);
P0=table[shi];
dula=1;
dula=0;
P0=0xff;
P0=tablewe[1];
wela=1;
wela=0;
delay(5);
P0=table[ge];
dula=1;
dula=0;
P0=0xff;
P0=tablewe[2];
wela=1;
wela=0;
delay(5);
}
void delay(unsigned char a) //延时子函数
{
unsigned char x,y;
for(x=a;x>0;x--)
for(y=100;y>0;y--);
}
程序如下,我应该怎么改?
#include<reg52.h>
sbit dula=P2^6;
sbit wela=P2^7;
unsigned char code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
unsigned char code tablewe[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf};
unsigned char temp,bai,shi,ge;
void display(unsigned char bai,shi,ge);
void delay(unsigned char a);
void main()
{
temp=163;
bai=temp/100;
shi=temp%100/10;
ge=temp%10;
dula=0;
wela=0;
while(1)
{
display(bai,shi,ge);
};
}
void display(unsigned char bai,shi,ge)
{
P0=table[bai];
dula=1;
dula=0;
P0=0xff;
P0=tablewe[0];
wela=1;
wela=0;
delay(5);
P0=table[shi];
dula=1;
dula=0;
P0=0xff;
P0=tablewe[1];
wela=1;
wela=0;
delay(5);
P0=table[ge];
dula=1;
dula=0;
P0=0xff;
P0=tablewe[2];
wela=1;
wela=0;
delay(5);
}
void delay(unsigned char a) //延时子函数
{
unsigned char x,y;
for(x=a;x>0;x--)
for(y=100;y>0;y--);
}
...
看下仿真图呢 并不影响吧
仿真过了,没有问题。
消隐部分没处理好!
谢谢啦谢谢啦谢谢啦
共同努力共同努力
把每个地方延时函数去掉,或者延时减小一点试试