#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};//共阳
void delay(unsigned int n)
{
unsigned char t;
while(n--)
{
for(t=0;t<120;t++);
}
}
void seg()
{
P0=0x01;
P2=s2[1];
delay(500);
P0=0x02;
P2=s2[2];
delay(500);
}
void main()
{ unsigned int i;
while(1)
{
seg();
}
}
间隔着显示1,2是正确的,你的疑问?