#include <reg52.h>
sbit SERB=P0^0;
sbit SRCLKB=P0^1;
sbit RCLKB=P0^2;
sbit SRCLKC=P0^3;
sbit RCLKC=P0^4;
sbit SERC=P0^5;
unsigned char code Led[]={0xFF,0xFF,0xC3,0x99,0xE7,0x00,0xE7,0x00,0xE7,0x00,
0xE7,0x81,0xC3,0xC3,0xFF,0xE7,0xFF,0xFF,0x99,0xFF,
0x99,0xFF,0xC3,0xFF,0xE7,0xFF,0xE7,0xFF,0xE7,0xFF,
0xFF,0xFF};
unsigned int Hang[]={0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,
0x0100,0x0200,0x0400,0x0800,0x1000,0x2000,0x4000,0x8000};
void SendHang(unsigned char A)
{
unsigned char i;
for(i=0;i<8;i++)
{
SRCLKB=0;
SERB=(A&0X80);
A<<=1;
SRCLKB=1;
}
}
void SendH(unsigned int B)
{
//unsigned int i;
unsigned char C;
C=(B>>8);
SendHang(C);
SendHang(B);
}
void SendLie(unsigned char K)
{
unsigned char i;
for(i=0;i<8;i++)
{
SRCLKC=0;
SERC=K&0X80;
K<<=1;
SRCLKC=1;
}
}
void SendLed(unsigned char M,unsigned char N)
{
//unsigned int i;
SendLie(M);
SendLie(N);
}
void main()
{
unsigned char i;
unsigned char ti;
while(1)
{
for(i=0;i<7;i++)
{
SendH(Hang[1]);
SendLed(0x99,0xc3);
RCLKC=1;
RCLKB=1;
RCLKC=0;
RCLKB=0;
SendLed(0xff,0xff);
}
}
} |