单数码管不改动数组进行逆循环的单片机程序
#include<reg51.h>
unsigned char code duan[]={
0xc0,0xf9,0xa4,0xb0,0x99,
0x92,0x82,0xf8,0x80,0x90};
void delay(unsigned int t)
{
unsigned int i,j;
for(i=0;i<t;i++)
for(j=0;j<120;j++);
}
void main()
{
unsigned char i;
while(1)
{
for(i=10;i>0;i--)
{
P3=duan[i-1];
delay(500);
}
}
} |