8只数码管显示多个不同字符
#include <reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar code duan[]={0xa4,0xc0,0xc0,0xc0,0xc0,0x82,0xa4,0x80};
uchar code wei[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
void delay(uint x)
{
uchar t;
while(–x)
{
for(t=0;t<120;t++);
}
}
void main()
{
uchar i,j;
P0=0xff;
P2=0x00;
j=0x80;
while(1)
{
for(i=0;i<8;i++)
{
P2=wei[i];
P0=duan[i];
delay(7);
P2=0x00;
j>>=i;
}
}
}