www.pudn.com > 74hc595-drive-1664-LED-module.rar > main.c, change:2015-01-01,size:1643b


#include <reg52.h> 
#include <ziku.h> 
#include <intrins.h> 
#define uchar unsigned char 
#define uint unsigned int  
void WriteInsideByte(unsigned int n); 
void WriteOutsideByte(unsigned int n); 
sbit SH_CP=P3^4; 
sbit DS=P3^3; 
sbit ST_CP=P3^5; 
uchar code a[ ]= 
{ 
	0x7f,0xff, 
	0xbf,0xff, 
	0xdf,0xff, 
	0xef,0xff, 
	0xf7,0xff, 
	0xfb,0xff, 
	0xfd,0xff, 
	0xfe,0xff, 
	 
	0xff,0x7f, 
	0xff,0xbf, 
	0xff,0xdf, 
	0xff,0xef, 
	0xff,0xf7, 
	0xff,0xfb, 
	0xff,0xfd, 
	0xff,0xfe, 
}; 
void delay(uint z) 
{ 
	uint x; 
	for(;z>0;z--) 
		for(x=11;x>0;x--); 
} 
 
void WriteInsideByte_h(uchar dat) 
{ 
	uchar k; 
	for(k=0;k<8;k++) 
	{ 
		dat=dat>>1; 
		DS=CY; 
		SH_CP=0; 
		SH_CP=1;		 
	} 
} 
 
void main() 
{ 
	int n=0,num,temp; 
	while(1) 
	{  
				temp=0; 
				for(num=0;num<16;num++) 
				{	 
					WriteInsideByte_h(tab[96+2*num+n+1]); 
					WriteInsideByte_h(tab[96+2*num+n+0]);			 
					WriteInsideByte_h(a[2*temp+1]);  
					WriteInsideByte_h(a[2*temp+0]);  
					 
					WriteInsideByte_h(tab[64+2*num+n+1]); 
					WriteInsideByte_h(tab[64+2*num+n+0]);			 
					WriteInsideByte_h(a[2*temp+1]);  
					WriteInsideByte_h(a[2*temp+0]);  
					 
					WriteInsideByte_h(tab[32+2*num+n+1]); 
					WriteInsideByte_h(tab[32+2*num+n+0]);			 
					WriteInsideByte_h(a[2*temp+1]);  
					WriteInsideByte_h(a[2*temp+0]);  
					 
					WriteInsideByte_h(tab[2*num+n+1]); 
					WriteInsideByte_h(tab[2*num+n+0]);			 
					WriteInsideByte_h(a[2*temp+1]);  
					WriteInsideByte_h(a[2*temp+0]); 				 
					temp++; 
					if(temp==16) 
						temp=0;					 
					ST_CP=0; 
					ST_CP=1; 
					delay(10); 
				}			 
		n=n+2; 
		if(n>=416) 
			n=0; 
		} 
	}