请问这个为什么是这么亮的


#include<reg51.h>
unsigned char s2[] = {0xc0, 0xf9, 0xa4, 0xb0,
0x99, 0x92, 0x82, 0xf8, 0x80, 0x90, 0x88,
0x83, 0xc6, 0xa1, 0x86, 0x8e, 0x8c, 0xc1,
0xce, 0x91, 0x89, 0xc7, 0xff};//共阳
static unsigned char sec = 0;
void delay(unsigned int n)
{
unsigned char t;
while(n--)
{
for(t=0;t<120;t++);
}
}
void seg()
{
P0=0x01;
P1=s2[1];
P0=0x02;
P1=s2[2];
}
void main()
{ unsigned int num=0;
while(1)
{
seg();
}
}


img

因为你切换位选择信号的时候没有加消隐处理,所以两个字母都是1和2的叠加,叠加起来就是这个效果了。

P0=0x01;
P1=s2[1];
P0=0x02;
P1=s2[2];
逐行分析吧,第一次执行到第二行的时候,还算正常,显示了第一个数字显示为1,第三行切换了位选信号,第二个数字亮了,但是这个时候第二个数字显示的内容还是前面的,还是1,后面显示效果以此类推。
正确的流程应该是这样

P0=0x01;
P1=s2[1];
delay()
P1 = off;//具体数值取决于是共阴还是共阳
P0=0x02;
P1=s2[2];
delay()
P1 = off;