分享关于单片机的内容,供大家学习。
#include <reg51.h>
void delay1s()
{
unsigned int i;
TMOD=0x10;
for(i=0;i<20;i++)
{TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
}
}
void main()
{
unsigned char code led [4][8]={{0x10,0x30,0x7f,0xff,0x7f,0x30,0x10,0x00},
{0x38,0x38,0x38,0x38,0xfe,0x7c,0x38,0x10},
{0x08,0x0c,0xfe,0xff,0xfe,0x0c,0x08,0x00},
{0x08,0x1c,0x3e,0x7f,0x1c,0x1c,0x1c,0x1c},};
unsigned char w;
unsigned int j,k,m;
while(1)
{
for(k=0;k<4;k++)
{
for(m=0;m<200;m++)
{
w=0x01;
for(j=0;j<8;j++)
{
P1=w;
P0=~led[k][j];
delay1s();
w<<=1;
P0=0xff;
}
}
}
}
}
|