动态数码管显示技术的程序
P0端口接动态数码管的字形码笔段,P2端口接动态数码管的数位选择端,P1.7接一个开关,当开关接高电平时,显示“12345”字样;
当开关接低电平时,显示“HELLO”字样。
#include <AT89X51.H>
unsigned char code table1[]={0x06,0x5b,0x4f,0x66,0x6d};
unsigned char code table2[]={0x78,0x79,0x38,0x38,0x3f};
unsigned char i;
unsigned char a,b;
unsigned char temp;
void main(void)
{
while(1)
{
temp=0xfe;
for(i=0;i <5;i++)
{
if(P1_7==1)
{
P0=table1;
}
else
{
P0=table2;
}
P2=temp;
a=temp < <(i+1);
b=temp> > (7-i);/*为什么是7-i*/
temp=a|b;
for(a=4;a> 0;a--)/*什么意思*/
for(b=248;b> 0;b--);/*什么意思*/
}
}
}
发表时间:2006年7月19日11:37:15