[mw_shl_code=c,true]#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit SCLK_164_1=P1^1;
sbit DATA_164_1=P1^2;
sbit SCLK_164_2=P1^3;
sbit DATA_164_2=P1^4;
sbit SCLK_595_1=P2^0;
sbit DATA_595_1=P2^1;
sbit LATCH_595_1=P2^2;
sbit SCLK_595_2=P2^3;
sbit DATA_595_2=P2^4;
sbit LATCH_595_2=P2^5;
unsigned char zancun[32];
unsigned char code shuzu[]={0x01,0x06,0x08,0x0A,0x00,0x94,0x00,0x92,0x55,0x00,0x37,0x00,0x52,0x00,0x00,0x38,0x00,0x4C,0x52,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
void delay(uint i)
{
int q=0;
for(q=0;q<i;q++);
}
void HC_595_1(uchar Data)
{
uchar i;
for(i=0;i<8;i++)
{
SCLK_595_1=0;
DATA_595_1=Data&0x01;
Data=Data>>1;
delay(5);
SCLK_595_1=1;
}
delay(50);
LATCH_595_1=0;
delay(10);
LATCH_595_1=1;
delay(10);
LATCH_595_1=0;
}
void HC_595_2(uint Data)//595??????????
{
uchar i;
for(i=0;i<8;i++)
{
SCLK_595_2=0;
DATA_595_2=Data&0x01;
Data=Data>>1;
delay(50);
SCLK_595_2=1;
}
delay(50);
LATCH_595_2=0;
delay(10);
LATCH_595_2=1;
delay(10);
LATCH_595_2=0;
}
void HC_164_1(uchar Data)
{
uchar i;
for(i=0;i<8;i++)
{
SCLK_164_1=0;
DATA_164_1=Data&0x01;
Data=Data>>1;
delay(10);
SCLK_164_1=1;
}
delay(10);
}
void HC_164_2(uchar Data)//164????
{
uchar i;
for(i=0;i<8;i++)
{
SCLK_164_2=0;
DATA_164_2=Data&0x01;
Data=Data>>1;
delay(10);
SCLK_164_2=1;
}
delay(10);
}
void Display()
{
uint i,j,q;
for(i=0;i<16;i++)
{
HC_595_1(zancun);
HC_595_2(0);
if(i<8)
{
HC_164_1(0x01<<i);
HC_164_2(0xFF);
delay(10);
HC_595_1(0);
HC_595_2(0);
}
else
{
HC_164_1(0xFF);
HC_164_2(0x01<<i);
delay(20);
HC_595_1(0);
HC_595_2(0);
}
j=i+16;
q=i-16;
HC_595_2(zancun[j]);
HC_595_1(0);
if(j<24)
{
HC_164_1(0x01<<q);
HC_164_2(0xFF);
delay(10);
HC_595_2(0);
HC_595_1(0);
}
else
{
HC_164_2(0x01<<q);
HC_164_1(0xFF);
delay(10);
HC_595_2(0);
HC_595_1(0);
}
}
}
void main()
{
int a;
delay(5000);
for(a=0;a<32;a++)
zancun[a]=shuzu[a];
while(1)
{
Display();
delay(50);
}
}
[/mw_shl_code]
|