#include<reg51.h>
void delay_ms(unsigned int xms);
unsigned int table[]={0xf9,0xf9,0xc0,0x92};
void main()
{
unsigned int i=0x01,k;
P0=0xff;
P2=0x00;
while(1)
{
for(k=0;k<4;k++)
{
P2=i;
P0=table[k];
delay_ms(1);
i=i<<1;
}
i=0x01;
}
}
void delay_ms(unsigned int xms)
{
unsigned int i,j;
for(i=0;i<xms;i++)
for(j=0;j<123;j++);
}
|