"); //-->
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit address0=P1^4;
sbit address1=P1^5;
sbit address2=P1^6;
sbit address3=P1^7;
uchar code scan[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
uchar code word1[32]={0xFF,0xFF,0x88,0xC9,0xD1,0xD5,0x94,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xF7,0xE3,0xDB,0xC1,0x18,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}
uchar temp[8];
void LED();
//void Delay1();
void Delay2(uchar NUM);
void Lock();
void main()
{
while(1)
{
LED();
// Delay(110);
}
}
void LED()
{
uchar j,CYC;
uchar m=8;
uchar symbol;
for(j=0;j<8;j++)
temp[j]=word1[j];
while(1)
{
for(CYC=100;CYC>0;CYC--)
Lock();
if(m>32)
m-=32;
symbol=word1[m];
for(j=0;j<7;j++)
{
temp[j]=temp[j+1];
}
temp[7]=symbol;
m++;
}
}
void Lock()
{
uchar i;
for(i=0;i<8;i++)
{
address0=0;
address1=0;
address2=0;
address3=0;
P0=0xFF;
address3=1;
address3=0;
address0=1;
address1=0;
address2=0;
P0=temp[i];
address3=1;
address3=0;
address0=0;
address1=0;
address2=0;
address3=0;
P0=scan[i];
address3=1;
address3=0;
Delay2(50);
}
}
//void Delay1()
//{
// uchar a,b;
// for(a=0;a<250;a++)
// for(b=0;b<110;b++);
//}
void Delay2(uchar NUM)
{
while(NUM--);
}
*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。