#include<reg51.h>
const unsigned char P0_arry[8]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
//const unsigned char P0_arry[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
//const unsigned char P2_arry[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
const unsigned char P2_arry[8]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
void delay(unsigned int time)
{
unsigned int i, j;
for(i = 0; i < time; i++)
for(j = 0; j < 120; j++);
}
void main()
{
unsigned char i, j;
while(1)
{
for(i=0;i<8;i++)
{
P2 = P2_arry[ i];
for(j=0;j<8;j++)
{
P0 = P0_arry[j];
delay(200);
}
}
}
} |