【开源DIY制作分享】采用STC15W408AS制作七彩LED广州塔

【广州塔DIY】采用STC15W408AS制作七彩LED广州塔


  • 之前在上升沿购买的散件led散件回来自己搭建的广州塔的,半年前突然就不亮了,这次重新购买回来了芯片,将程序烧录进去,重新恢复了。采用的单片机是STC15W408AS-35I-SKDIP28
    在这里插入图片描述
  • 找了其他网上的广州塔LED代码,烧录进去,效果不理想,有的采用的是共阴极焊接的,有的能亮但是,显示的效果都不多,没有原来之前芯片里面自带程序的效果多,今天想到免去淘宝翻一翻你是记录,看看,能不能找到资料,果真,还有,立马下载下来,将里面附带的程序烧录进去,效果和原来的一样了。特此分享出来,完全可以自己去嘉立创打板,自己做,成本的话也就10块钱的成本完全够,去TB购买散件需要25元左右,对于电子DIY,最重要的就是程序和原理图了,有了这两样基本上制作都没有什么难度了,所以分享出来,让后面的人如果想自己动手制作,完全可以按照这里的资料自己制作。
  • STC15W408AS-35I-SKDIP28
    在这里插入图片描述
  • Led灯的价格很便宜的,一大包要不了多少钱,然后就是4个电阻。

制作所需材料(包含教程原理图,程序,焊接教程)

链接: https://pan.baidu.com/s/1DKJq5fa0UdwnCnK4ic_gTw 
提取码: edjc 
  • 资料截图
    在这里插入图片描述

在这里插入图片描述

  • 实际焊接的骨架效果取决于个人的焊接水平。凑合着看吧
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

程序代码

/*共阳极LED灯焊接***/

#include "STC15F2K.h"
#include "intrins.h"
#include <math.h>

#define uchar unsigned char 
#define uint unsigned int

sbit L1=P2^5;
sbit L2=P2^6;
sbit L3=P2^7;
sbit L4=P1^1;
sbit L5=P1^2;
sbit L6=P1^3;
sbit L7=P3^7;
sbit L8=P2^0;
sbit L9=P2^1;
sbit L10=P2^2;
sbit L11=P2^3;
sbit L12=P2^4;

sbit C1=P3^0;
sbit C2=P3^1;
sbit C3=P3^3;
sbit C4=P3^4;
sbit C5=P3^5;
sbit C6=P3^6;
sbit C7=P1^4;
sbit C8=P1^5;
sbit C9=P1^6;
sbit C10=P1^7;
sbit C11=P5^4;
sbit C12=P5^5;

sbit hwx=P3^2;		//红外接收数据引脚,

unsigned char ly_lhj[4];					//保存NEC的四个字节数据
bit ly_flag=0;								//成功接收标志

unsigned int temp;

char moshi=1;
int hys=100;
char zy=0,sj=0;

void Delayms(uint t)
{
 	uchar i;
	while(t--)
	   for(i=0;i<hys;i++);
}

void bjc()//层变化
{
	L1=L2=L3=L4=L5=L6=L7=L8=L9=L10=L11=L12=1;
	if(sj==0)
	{
		C1=0;C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=1;
	}

	if(sj==1)
	{
		C1=1;C2=0;C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=1;
	}

	if(sj==2)
	{
		C1=C2=1;C3=0;C4=C5=C6=C7=C8=C9=C10=C11=C12=1;
	}
	if(sj==3)
	{
		C1=C2=C3=1;C4=0;C5=C6=C7=C8=C9=C10=C11=C12=1;
	}

	if(sj==4)
	{
		C1=C2=C3=C4=1;C5=0;C6=C7=C8=C9=C10=C11=C12=1;	
	}
	if(sj==5)
	{
		C1=C2=C3=C4=C5=1;C6=0;C7=C8=C9=C10=C11=C12=1;	
	}
	if(sj==6)
	{
		C1=C2=C3=C4=C5=C6=1;C7=0;C8=C9=C10=C11=C12=1;
	}
	if(sj==7)
	{
		C1=C2=C3=C4=C5=C6=C7=1;C8=0;C9=C10=C11=C12=1;	
	}
	if(sj==8)
	{
		C1=C2=C3=C4=C5=C6=C7=C8=1;C9=0;C10=C11=C12=1;	
	}
	if(sj==9)
	{
		C1=C2=C3=C4=C5=C6=C7=C8=C9=1;C10=0;C11=C12=1;	
	}
	if(sj==10)
	{
		C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=1;C11=0;C12=1;	
	}
	if(sj==11)
	{
		C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=1;C12=0;	
	}
}
void bjs()//竖变化
{
	C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=0;		
	if(zy==0)
	{
		L1=1;L2=L3=L4=L5=L6=0;L7=1;L8=L9=L10=L11=L12=0;
	}

	if(zy==1)
	{
		L1=0;L2=1;L3=L4=L5=L6=L7=0;L8=1;L9=L10=L11=L12=0;
	}	

	if(zy==2)
	{
		L1=L2=0;L3=1;L4=L5=L6=L7=L8=0;L9=1;L10=L11=L12=0;
	}	

	if(zy==3)
	{
		L1=L2=L3=0;L4=1;L5=L6=L7=L8=L9=0;L10=1;L11=L12=0;
	}	

	if(zy==4)
	{
		L1=L2=L3=L4=0;L5=1;L6=L7=L8=L9=L10=0;L11=1;L12=0;
	}	

	if(zy==5)
	{
		L1=L2=L3=L4=L5=0;L6=1;L7=L8=L9=L10=L11=0;L12=1;	
	}	
}

void dh1()
{
	int time=1200;
	L1=L2=L3=L4=L5=L6=L7=L8=L9=L10=L11=L12=1;
	C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=1;
	C1=0;
	Delayms(time);
	C2=0;
	Delayms(time);
	C3=0;
	Delayms(time);
	C4=0;
	Delayms(time);
	C5=0;
	Delayms(time);
	if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	C6=0;
	Delayms(time);
	C7=0;
	Delayms(time);	
	C8=0;
	Delayms(time);
	C9=0;
	Delayms(time);
	C10=0;
	Delayms(time);
	C11=0;
	Delayms(time);
	C12=0;
	if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	Delayms(8000);
	if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	Delayms(8000);
	if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	Delayms(8000);
	if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	Delayms(8000);
	if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	Delayms(8000);
	if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	Delayms(8000);
	if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	Delayms(8000);
	if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	Delayms(8000);
	if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	Delayms(8000);
	if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	Delayms(8000);
	if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	Delayms(8000);
	C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=1;
hm:;
}
void dh2()
{
	int time=1000,i;
	C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=0;
	L1=L2=L3=L4=L5=L6=L7=L8=L9=L10=L11=L12=0;

	for(i=0;i<12;i++)
	{
		L1=1;
		L7=1;
		Delayms(time);
		L1=0;
		L7=0;
	
		L2=1;
		L8=1;
		Delayms(time);
		L2=0;
		L8=0;
	
		L3=1;
		L9=1;
		Delayms(time);
		L3=0;
		L9=0;
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}	
		L4=1;
		L10=1;
		Delayms(time);
		L4=0;
		L10=0;
	
		L5=1;
		L11=1;
		Delayms(time);
		L5=0;
		L11=0;
	
		L6=1;
		L12=1;
		Delayms(time);
		L6=0;
		L12=0;	
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	}
hm:;	
}

void dh3()
{
	char i;
	int time=500;
	L1=L2=L3=L4=L5=L6=L7=L8=L9=L10=L11=L12=1;
	C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=1;

	for(i=0;i<4;i++)
	{
		C1=0;
		Delayms(time);
		C1=1;
		C2=0;
		Delayms(time);
		C2=1;
		C3=0;
		Delayms(time);
		C3=1;
		C4=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		C4=1;
		C5=0;
		Delayms(time);
		C5=1;
		C6=0;
		Delayms(time);
		C6=1;
		C7=0;
		Delayms(time);
		C7=1;
		C8=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		C8=1;
		C9=0;
		Delayms(time);
		C9=1;
		C10=0;
		Delayms(time);
		C10=1;
		C11=0;
		Delayms(time);
		C11=1;
		C12=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		C12=1;
		C11=0;
		Delayms(time);
		C11=1;
		C10=0;
		Delayms(time);
		C10=1;
		C9=0;
		Delayms(time);
		C9=1;
		C8=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		C8=1;
		C7=0;
		Delayms(time);
		C7=1;
		C6=0;
		Delayms(time);
		C6=1;
		C5=0;
		Delayms(time);
		C5=1;
		C4=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		C4=1;
		C3=0;
		Delayms(time);
		C3=1;
		C2=0;
		Delayms(time);
		C2=1;	
	}
hm:;
}
void dh4()
{
	char i;
	int time=800;
	L1=L2=L3=L4=L5=L6=L7=L8=L9=L10=L11=L12=1;
	C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=1;

	for(i=0;i<4;i++)
	{
		C6=0;
		C7=0; 
		C1=1;
		C12=1;
		Delayms(time);
		C6=1;
		C7=1;
		C5=0;
		C8=0;
		Delayms(time);
		C4=0;
		C9=0;
		C5=1;
		C8=1;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		C4=1;
		C9=1;
		C3=0;
		C10=0;
		Delayms(time);
		C2=0;
		C11=0;
		C3=1;
		C10=1;
		Delayms(time);
		C2=1;
		C11=1;
		C1=0;
		C12=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	}
	C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=0;
hm:;
}
void dh5()
{
	int time=800;
	C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=0;
	L1=L2=L3=L4=L5=L6=L7=L8=L9=L10=L11=L12=0;

	L1=1;
	Delayms(time);
	L2=1;
	Delayms(time);
	L3=1;
	Delayms(time);
	L4=1;
	Delayms(time);
	if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	L5=1;
	Delayms(time);
	L6=1;
	Delayms(time);
	L7=1;
	Delayms(time);
	L8=1;
	Delayms(time);
	if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	L9=1;
	Delayms(time);
	L10=1;
	Delayms(time);
	L11=1;
	Delayms(time);
	L12=1;
	Delayms(time);	
	if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	Delayms(8000);
	if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	Delayms(8000);
	if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	Delayms(8000);
	if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	Delayms(8000);
	if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	Delayms(8000);
	if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	Delayms(8000);
	if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	Delayms(8000);
	if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	Delayms(8000);
hm:;
}
void dh6()
{
	char i;
	int time=500;
	C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=0;
	L1=L2=L3=L4=L5=L6=L7=L8=L9=L10=L11=L12=0;
	for(i=0;i<10;i++)
	{
		L1=L4=L7=L10=1;
		Delayms(time);
		L1=L4=L7=L10=0;
		L2=L5=L8=L11=1;
		Delayms(time);
		L3=L6=L9=L12=1;
		L2=L5=L8=L11=0;
		Delayms(time);
		L3=L6=L9=L12=0;
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	}
hm:;
}
void dh7()
{
	int i,time=500;
	L1=L2=L3=L4=L5=L6=L7=L8=L9=L10=L11=L12=1;
	C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=1;
	C12=0;
	for(i=0;i<2;i++)
	{
		C11=0;
		Delayms(time);
		C11=1;
		C10=0;
		Delayms(time);
		C10=1;
		C9=0;
		Delayms(time);
		C9=1;
		C8=0;
		Delayms(time);
		C8=1;
		C7=0;
		Delayms(time);
		C7=1;
		C6=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		C6=1;
		C5=0;
		Delayms(time);
		C5=1;
		C4=0;
		Delayms(time);
		C4=1;
		C3=0;
		Delayms(time);
		C3=1;
		C2=0;
		Delayms(time);
		C2=1;
		C1=0;
		Delayms(time);
	
		C11=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		C11=1;
		C10=0;
		Delayms(time);
		C10=1;
		C9=0;
		Delayms(time);
		C9=1;
		C8=0;
		Delayms(time);
		C8=1;
		C7=0;
		Delayms(time);
		C7=1;
		C6=0;
		Delayms(time);
		C6=1;
		C5=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		C5=1;
		C4=0;
		Delayms(time);
		C4=1;
		C3=0;
		Delayms(time);
		C3=1;
		C2=0;
		Delayms(time);
	
		C11=0;
		Delayms(time);
		C11=1;
		C10=0;
		Delayms(time);
		C10=1;
		C9=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		C9=1;
		C8=0;
		Delayms(time);
		C8=1;
		C7=0;
		Delayms(time);
		C7=1;
		C6=0;
		Delayms(time);
		C6=1;
		C5=0;
		Delayms(time);
		C5=1;
		C4=0;
		Delayms(time);
		C4=1;
		C3=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		C11=0;
		Delayms(time);
		C11=1;
		C10=0;
		Delayms(time);
		C10=1;
		C9=0;
		Delayms(time);
		C9=1;
		C8=0;
		Delayms(time);
		C8=1;
		C7=0;
		Delayms(time);
		C7=1;
		C6=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		C6=1;
		C5=0;
		Delayms(time);
		C5=1;
		C4=0;
		Delayms(time);
	
		C11=0;
		Delayms(time);
		C11=1;
		C10=0;
		Delayms(time);
		C10=1;
		C9=0;
		Delayms(time);
		C9=1;
		C8=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		C8=1;
		C7=0;
		Delayms(time);
		C7=1;
		C6=0;
		Delayms(time);
		C6=1;
		C5=0;
		Delayms(time);
	
		C11=0;
		Delayms(time);
		C11=1;
		C10=0;
		Delayms(time);
		C10=1;
		C9=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		C9=1;
		C8=0;
		Delayms(time);
		C8=1;
		C7=0;
		Delayms(time);
		C7=1;
		C6=0;
		Delayms(time);
	
		C11=0;
		Delayms(time);
		C11=1;
		C10=0;
		Delayms(time);
		C10=1;
		C9=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		C9=1;
		C8=0;
		Delayms(time);
		C8=1;
		C7=0;
		Delayms(time);
	
		C11=0;
		Delayms(time);
		C11=1;
		C10=0;
		Delayms(time);
		C10=1;
		C9=0;
		Delayms(time);
		C9=1;
		C8=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	
		C11=0;
		Delayms(time);
		C11=1;
		C10=0;
		Delayms(time);
		C10=1;
		C9=0;
		Delayms(time);
	
		C11=0;
		Delayms(time);
		C11=1;
		C10=0;
		Delayms(time);
	
		C11=0;
		Delayms(time);		
	}
hm:;		
} 
void dh8()
{
	int i,time=800;
	L1=L2=L3=L4=L5=L6=L7=L8=L9=L10=L11=L12=1;	
									  
	for(i=0;i<6;i++)
	{
		C9=1;
		C10=1;
		C3=1;
		C4=1;

		C7=0;
		C12=0;
		
		C1=0;
		C6=0;
		Delayms(time);
		
		C7=1;
		C12=1;
		
		C1=1;
		C6=1;

		C8=0;
		C11=0;

		C2=0;
		C5=0;
		Delayms(time);	
		
		C8=1;
		C11=1;

		C2=1;
		C5=1;

		C9=0;
		C10=0;
		C3=0;
		C4=0;
		Delayms(time);	
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}	
	}
hm:;
}
void dh9()
{
	int i,time=1000;
	L1=L2=L3=L4=L5=L6=L7=L8=L9=L10=L11=L12=1;	
	for(i=0;i<3;i++)
	{
		C12=C11=C10=C9=0;
		Delayms(time);
		C12=1;C11=C10=C9=C8=0;
		Delayms(time);
		C11=1;C10=C9=C8=C7=0;
		Delayms(time);
		C10=1;C9=C8=C7=C6=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		C9=1;C8=C7=C6=C5=0;
		Delayms(time);
		C8=1;C7=C6=C5=C4=0;
		Delayms(time);
		C7=1;C6=C5=C4=C3=0;
		Delayms(time);
		C6=1;C5=C4=C3=C2=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		C5=1;C4=C3=C2=C1=0;
		Delayms(time);
		C4=1;C3=C2=C1=0;
		Delayms(time);
		C3=1;C2=C1=0;
		Delayms(time);
		C2=1;C1=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		C1=1;
		Delayms(time);	
	}
hm:;	
}
void dh10()
{
	int i,time=1100;
	L1=L2=L3=L4=L5=L6=L7=L8=L9=L10=L11=L12=1;	
	for(i=0;i<3;i++)
	{
		C6=C7=0;
		Delayms(time);
		C5=C8=0;
		Delayms(time);
		C4=C9=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		C3=C10=0;
		Delayms(time);
		C2=C11=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		C1=C12=0;
		Delayms(8000);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		Delayms(8000);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		Delayms(8000);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		Delayms(8000);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		Delayms(8000);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		Delayms(8000);
		C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=1;
	}
hm:;	
}
void dh11()
{
	int i,time=1100;
	L1=L2=L3=L4=L5=L6=L7=L8=L9=L10=L11=L12=1;	
	for(i=0;i<3;i++)
	{
		C12=0;
		Delayms(time);
		C11=0;
		Delayms(time);
		C10=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		C9=0;
		Delayms(time);
		C8=0;
		Delayms(time);
		C7=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		C6=0;
		Delayms(time);
		C5=0;
		Delayms(time);
		C4=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		C3=0;
		Delayms(time);
		C2=0;
		Delayms(time);
		C1=0;
		Delayms(8000);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		Delayms(8000);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		Delayms(8000);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		Delayms(8000);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		Delayms(8000);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		Delayms(8000);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		Delayms(8000);
		C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=1;
	}
hm:;	
}
void dh12()
{
	int time=1000,i;
	C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=1;

	for(i=0;i<12;i++)
	{
		if(i==0)C1=0;
		if(i==1)C2=0;
		if(i==2)C3=0;
		if(i==3)C4=0;
		if(i==4)C5=0;
		if(i==5)C6=0;
		if(i==6)C7=0;
		if(i==7)C8=0;
		if(i==8)C9=0;
		if(i==9)C10=0;
		if(i==10)C11=0;
		if(i==11)C12=0;

		L1=1;
		L7=1;
		Delayms(time);
		L1=0;
		L7=0;
	
		L2=1;
		L8=1;
		Delayms(time);
		L2=0;
		L8=0;
	
		L3=1;
		L9=1;
		Delayms(time);
		L3=0;
		L9=0;
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		L4=1;
		L10=1;
		Delayms(time);
		L4=0;
		L10=0;
	
		L5=1;
		L11=1;
		Delayms(time);
		L5=0;
		L11=0;
	
		L6=1;
		L12=1;
		Delayms(time);
		L6=0;
		L12=0;	
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
	}
hm:;
}
void dh13()
{
	int time=1000,i;
	C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=1;

	for(i=0;i<6;i++)
	{
		if(i==0){C6=C7=0;}
		if(i==1){C5=C8=0;}
		if(i==2){C4=C9=0;}
		if(i==3){C3=C10=0;}
		if(i==4){C2=C11=0;}
		if(i==5){C1=C12=0;}

		L1=1;
		L7=1;
		Delayms(time);
		L1=0;
		L7=0;
	
		L2=1;
		L8=1;
		Delayms(time);
		L2=0;
		L8=0;
	
		L3=1;
		L9=1;
		Delayms(time);
		L3=0;
		L9=0;
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		L4=1;
		L10=1;
		Delayms(time);
		L4=0;
		L10=0;
	
		L5=1;
		L11=1;
		Delayms(time);
		L5=0;
		L11=0;
	
		L6=1;
		L12=1;
		Delayms(time);
		L6=0;
		L12=0;
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}	
	}
hm:;
}
void dh14()
{
	int i,time=500;
	C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=1;
	L1=L2=L3=L4=L5=L6=L7=L8=L9=L10=L11=L12=0;
	for(i=0;i<12;i++)
	{
		if(i==0){C1=0;C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=1;}
		if(i==1){C1=1;C2=0;C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=1;}
		if(i==2){C1=C2=1;C3=0;C4=C5=C6=C7=C8=C9=C10=C11=C12=1;}
		if(i==3){C1=C2=C3=1;C4=0;C5=C6=C7=C8=C9=C10=C11=C12=1;}
		if(i==4){C1=C2=C3=C4=1;C5=0;C6=C7=C8=C9=C10=C11=C12=1;}
		if(i==5){C1=C2=C3=C4=C5=1;C6=0;C7=C8=C9=C10=C11=C12=1;}
		if(i==6){C1=C2=C3=C4=C5=C6=1;C7=0;C8=C9=C10=C11=C12=1;}
		if(i==7){C1=C2=C3=C4=C5=C6=C7=1;C8=0;C9=C10=C11=C12=1;}
		if(i==8){C1=C2=C3=C4=C5=C6=C7=C8=1;C9=0;C10=C11=C12=1;}
		if(i==9){C1=C2=C3=C4=C5=C6=C7=C8=C9=1;C10=0;C11=C12=1;}
		if(i==10){C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=1;C11=0;C12=1;}
		if(i==11){C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=1;C12=0;}	
		L1=1;
		Delayms(time);
		L1=0;
		L2=1;
		Delayms(time);
		L2=0;
		L3=1;
		Delayms(time);
		L3=0;
		L4=1;
		Delayms(time);
		L4=0;
		L5=1;
		Delayms(time);
		L5=0;
		L6=1;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		L6=0;
		L7=1;
		Delayms(time);
		L7=0;
		L8=1;
		Delayms(time);
		L8=0;
		L9=1;
		Delayms(time);
		L9=0;
		L10=1;
		Delayms(time);
		L10=0;
		L11=1;
		Delayms(time);
		L11=0;
		L12=1;
		Delayms(time);
		L12=0;	
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}	
	}
hm:;
}
void dh15()
{
	int i,time=500;
	C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=1;
	L1=L2=L3=L4=L5=L6=L7=L8=L9=L10=L11=L12=0;
	for(i=0;i<12;i++)
	{
		if(i==0){C1=0;C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=1;}
		if(i==1){C1=1;C2=0;C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=1;}
		if(i==2){C1=C2=1;C3=0;C4=C5=C6=C7=C8=C9=C10=C11=C12=1;}
		if(i==3){C1=C2=C3=1;C4=0;C5=C6=C7=C8=C9=C10=C11=C12=1;}
		if(i==4){C1=C2=C3=C4=1;C5=0;C6=C7=C8=C9=C10=C11=C12=1;}
		if(i==5){C1=C2=C3=C4=C5=1;C6=0;C7=C8=C9=C10=C11=C12=1;}
		if(i==6){C1=C2=C3=C4=C5=C6=1;C7=0;C8=C9=C10=C11=C12=1;}
		if(i==7){C1=C2=C3=C4=C5=C6=C7=1;C8=0;C9=C10=C11=C12=1;}
		if(i==8){C1=C2=C3=C4=C5=C6=C7=C8=1;C9=0;C10=C11=C12=1;}
		if(i==9){C1=C2=C3=C4=C5=C6=C7=C8=C9=1;C10=0;C11=C12=1;}
		if(i==10){C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=1;C11=0;C12=1;}
		if(i==11){C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=1;C12=0;}	
		L1=1;
		Delayms(time);
		L2=1;
		Delayms(time);
		L3=1;
		Delayms(time);
		L4=1;
		Delayms(time);
		L5=1;
		Delayms(time);
		L6=1;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		L7=1;
		Delayms(time);
		L8=1;
		Delayms(time);
		L9=1;
		Delayms(time);
		L10=1;
		Delayms(time);
		L11=1;
		Delayms(time);
		L12=1;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		L1=L2=L3=L4=L5=L6=L7=L8=L9=L10=L11=L12=0;		
	}
hm:;
}
void dh16()
{
	int i,time=300;
	C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=1;
	L1=L2=L3=L4=L5=L6=L7=L8=L9=L10=L11=L12=0;
	for(i=0;i<12;i++)
	{
		if(i==0 || i==2 || i==4 ||i==6 ||i==8 ||i==10){L1=0;L7=1;}
		if(i==1 || i==3 || i==5 ||i==7 ||i==9 ||i==11){L1=1;L7=0;}
		C1=0;
		Delayms(time);
		C1=1;C2=0;
		Delayms(time);
		C3=0;C2=1;
		Delayms(time);
		C3=1;C4=0;
		Delayms(time);
		C4=1;C5=0;
		Delayms(time);
		C5=1;C6=0;
		Delayms(time);
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}
		C6=1;C7=0;
		Delayms(time);
		C7=1;C8=0;
		Delayms(time);
		C8=1;C9=0;
		Delayms(time);
		C9=1;C10=0;
		Delayms(time);
		C10=1;C11=0;
		Delayms(time);
		C11=1;C12=0;;
		Delayms(time);
		C12=1;	
		if(ly_flag==1){moshi=0;ly_flag=0;goto hm;}	
	}
hm:;
}

void init()
{
    TMOD= 0x11;				   
    TL0 = 0;        //设置定时初值
    TH0 = 0;        //设置定时初值

	EX0=1;  				//开启外部中断0
	IT0=1;        			//设置成下降沿触发方式

    EA = 1;
}

void main()
{
	P3M0=0xff;P3M1=0x04;
	P2M0=0xff;P2M1=0x00;
	P1M0=0xff;P1M1=0x00;
	P5M0=0xff;P5M1=0x00;
	init();

	while(1)
	{
		if(moshi==1)dh1();
		if(moshi==1)dh2();
		if(moshi==1)dh3();
		if(moshi==1)dh4();
		if(moshi==1)dh5();
		if(moshi==1)dh6();
		if(moshi==1)dh7();
		if(moshi==1)dh8();
		if(moshi==1)dh9();
		if(moshi==1)dh10();
		if(moshi==1)dh11();
		if(moshi==1)dh12();
		if(moshi==1)dh13();
		if(moshi==1)dh14();
		if(moshi==1)dh15();
		if(moshi==1)dh16();

		//调试模式
		if(moshi==3)bjs();							
		if(moshi==4)bjc();
	}
}

void delayh(void){		
	unsigned char i=200;
	while(i--);
}
 /***********外中断0入口函数,P32引脚,红外线接收IC数据脚**************************/
void hongwai(void)   interrupt 0
{
	unsigned char i,ia;
	/**************开始判断是否为NEC波形引导码的前9MS和后4.5MS******************************/
	TL0=0;
	TH0=0;				//定时/计数器1初始值
	TR0=1;				//定时器以12M晶振12分频计数,即1us计数
	while(!hwx);
	TR0=0;				//信号翻转停止计数
	if(TH0<30||TH0>40)	//NEC引导码前9MS,计数约9000,TH1约等于35,给个误差值,用30-40之间来判断
		return;

	TH0=0;				//定时/计数器1初始值
	TR0=1;
	while(hwx){
		delayh();
		if(TH0>22)		//NEC引导码引导码的后4。5MS,计数约4500,TH1约等于17
			return;		
	}
	TR0=0;
	if(TH0<12)			//NEC引导码引导码的后4。5MS,计数约4500,TH1约等于17
		return;

	/***********开始接收四个字节内容**************************************/	
	for(i=0;i<4;i++){
		for(ia=0;ia<8;ia++){				
			while(!hwx);	//低电平开始,不处理只等待高电平
			
			TH0=0;
			TR0=1;			//高电平开始,启动计数
			while(hwx){
				delayh();
				if(TH0>15)		
					return;		
			}
			TR0=0;
			//高电平结束,判断数据1或0向变量移入
			ly_lhj[i]>>=1;			//数据由高位移入低位
			if(TH0>4)				//时间量TH1高于4,即高于1MS判断为1
				ly_lhj[i]|=0x80;
		}
	}

	if(ly_lhj[2]==0x15)//动画模式
	{
		moshi=1;
		IE2=0X00;
	}

	if(ly_lhj[2]==0x45)//全灭
	{
		moshi=2;IE2=0X00;
		L1=L2=L3=L4=L5=L6=L7=L8=L9=L10=L11=L12=0;
		C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=1;   	
	}
	if(ly_lhj[2]==0x47)//全灭
	{
		moshi=2;IE2=0X00;
		L1=L2=L3=L4=L5=L6=L7=L8=L9=L10=L11=L12=1;
		C1=C2=C3=C4=C5=C6=C7=C8=C9=C10=C11=C12=0;   		
	}

	if(ly_lhj[2]==0x5E)//动画速度减速
	{
		if(hys<1000)hys=hys+10;
	}

	if(ly_lhj[2]==0x5A)//动画速度减速
	{
		if(hys>10)hys=hys-10;
	}

	if(ly_lhj[2]==0x4A)//动画速度复位
	{
		hys=100;
	}

	if(ly_lhj[2]==0x44)//编辑竖模式
	{
		moshi=4;ly_flag=1;IE2=0X00;
	}
	if(ly_lhj[2]==0x43)//编辑层模式
	{
		moshi=3;ly_flag=1;IE2=0X00;
	}

	if(moshi==3)
	{
		if(ly_lhj[2]==0x07)//左移
		{
			zy++;if(zy>6)zy=0;	
		}
	
		if(ly_lhj[2]==0x09)//右移
		{
			zy--;if(zy<0)zy=5;		
		}
	}
	if(moshi==4)
	{
		if(ly_lhj[2]==0x40)//上升
		{
			sj++;if(sj>11)sj=11;
		}
	
		if(ly_lhj[2]==0x19)//下降
		{
			sj--;if(sj<0)sj=0;	
		}
	}

	TF1=0;
}
  • 8
    点赞
  • 35
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值