旋转LED灯-(摇摇棒)

参加了学校的电子设计大赛,比赛结果让人蛋碎一地!

我选择的是B题--旋转LED,因为简单所以不少人都选择了这题。题目要求是通过电机带动16盏LED显示文字和一个60s秒针,并且LED亮度随着环境亮度变化而变化。拿到题目的时候的我们都有点蒙逼,当时找老师的时候我们几个也是不明觉厉。后来在寝室各种百度,结果网上搜索了一大堆制作教程,完全出乎我的意料啊。呵呵呵。并且我也发现了一个关于电子的非常棒的网站--中国电子DIY之家,里面有各种LED、音箱、智能小车、特斯拉线圈等等,总之有各路高手坐镇,我感受到了DIY的乐趣。

制作过程:

旋转LED是利用POV原理显示文字或者图案,首先我们的思路是直流电机固定在板子上面,由于惯性太大最后采用了抽屉代替,这样电机转起来比较稳,然后在电机轴上固定一块长方形的洞洞板,洞洞板上面焊接电路,自动调光用到AD转换,然后通过改暂空比调节LED亮度,AD转换没用到单独的AD芯片,而是采用STC12C5A6S2这款芯片内部自带的AD,显示文字就用点阵扫描原理,往16个LED里送点阵字符,由于电机转速足够快,我们看到显示字符就不会出现闪烁,显示60s秒针用到定时器,计时到1s会距离标志杆一个位置,然后累加,最后计时到60s之后进行重新计时。

元器件:电阻、STC12C5A60S2、电容、红外接收头、红外遥控器、发光二极管。

proteus画的电路图

实物图

显示效果

源程序

#include <STC12C5A.H>                                                   
#include "intrins.h" 
#define uchar unsigned char
#define uint unsigned int
#define _Nop() _nop_()
uchar i;
uint j=0;
uint a;
uchar IrValue[6];
uchar Time;
uchar count=0;
uchar seconds=0;
float num;
sbit IRIN=P3^2;
sbit KEY=P2^4;
sbit PB1=P2^0;
sbit PB2=P2^1;
sbit PB3=P2^2;
sbit PB4=P2^3;
uchar code SB1[]={0xFF,0xFF,0xF7,0xDF,0xF7,0xDF,0x07,0xC0,0xF7,0xDF,0xF7,0xDF,0xFF,0xFF,0xFF,0xFF,0xE7,0xFF,0xF7,0xFF,0xF7,0xDF,0x07,0xC0,0xF7,0xDF,0xF7,0xFF,0xE7,0xFF,0xFF,0xFF};
uchar code SB2[]={0xFF,0xFF,0xFF,0xFF,0x07,0xE0,0x77,0xF7,0x77,0xF7,0x77,0xF7,0x77,0xF7,0x00,0x80,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x07,0x60,0xFF,0x7F,0xFF,0x0F,0xFF,0xFF};
uchar code tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
uchar code tab1[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
uchar code nb[]={0xFB,0xFF,0xF9,0xFF,0x00,0x00,0xF9,0xFF,0xFB,0xFF};
uchar code db[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xF8,0x1F,0x88,0x08,0x88,0x08,0x88,0x08,0x88,0x08,0xFF,0x7F,
0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0xF8,0x9F,0x00,0x80,0x00,0xF0,0x00,0x00,
0x80,0x00,0x82,0x00,0x82,0x00,0x82,0x00,0x82,0x00,0x82,0x40,0x82,0x80,0xE2,0x7F,
0xA2,0x00,0x92,0x00,0x8A,0x00,0x86,0x00,0x82,0x00,0x80,0x00,0x80,0x00,0x00,0x00,
0x00,0x01,0x80,0x00,0x60,0x00,0xF8,0xFF,0x07,0x00,0x00,0x00,0x04,0x00,0x24,0xF9,
0x24,0x49,0x25,0x49,0x26,0x49,0x24,0x49,0x24,0x49,0x24,0xF9,0x04,0x00,0x00,0x00,
0x00,0x40,0x00,0x30,0x00,0x00,0xFC,0x03,0x54,0x39,0x54,0x41,0x56,0x41,0x55,0x45,
0x54,0x59,0x54,0x41,0x54,0x41,0xFC,0x73,0x00,0x00,0x00,0x08,0x00,0x30,0x00,0x00,
0x00,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0xFC,0x3F,
0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x00,0x20,0x00,0x00,
0x24,0x08,0x24,0x06,0xA4,0x01,0xFE,0xFF,0x23,0x01,0x22,0x06,0x00,0x40,0x3E,0x49,
0x22,0x49,0x22,0x49,0x22,0x7F,0x22,0x49,0x22,0x49,0x3E,0x49,0x00,0x41,0x00,0x00,
0x40,0x04,0x30,0x04,0x11,0x04,0x96,0x04,0x90,0x04,0x90,0x44,0x91,0x84,0x96,0x7E,
0x90,0x06,0x90,0x05,0x98,0x04,0x14,0x04,0x13,0x04,0x50,0x04,0x30,0x04,0x00,0x00,
0x00,0x00,0xFE,0xFF,0x22,0x04,0x5A,0x08,0x86,0x07,0x10,0x80,0x0C,0x41,0x24,0x31,
0x24,0x0F,0x25,0x01,0x26,0x01,0x24,0x3F,0x24,0x41,0x14,0x41,0x0C,0x71,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x20,0x00,0x18,0x00,0x08,0x3E,0xEA,0x02,0xAC,0x02,0xA8,0x02,0xA8,0x02,0xAF,0xFF,
0xA8,0x02,0xA8,0x02,0xAC,0x12,0xEA,0x22,0x08,0x1E,0x28,0x00,0x18,0x00,0x00,0x00,
0x10,0x04,0x60,0x04,0x02,0x7E,0x8C,0x01,0x00,0x00,0xFC,0xFF,0x01,0x00,0x16,0x11,
0x10,0x11,0xF2,0x1F,0x12,0x11,0x12,0x51,0x02,0x80,0xFE,0x7F,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x20,0x18,0x10,0x16,0x8C,0x10,0x83,0xD0,0x80,0xB8,0x41,0x97,0x46,
0x90,0x28,0x90,0x10,0x90,0x28,0x92,0x44,0x94,0x43,0x10,0x80,0x00,0x80,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x10,0x04,0x10,0x03,0xD0,0x00,0xFF,0xFF,0x90,0x00,0x10,0x23,0x00,0x10,0x42,0x8C,
0xE2,0x43,0x52,0x20,0x4A,0x18,0xC6,0x47,0x42,0x80,0x40,0x40,0xC0,0x3F,0x00,0x00,
0x5E,0x00,0x50,0x7E,0x50,0x42,0x5F,0x22,0x50,0x22,0x50,0x12,0xDE,0x93,0x00,0x60,
0xFE,0x1F,0x02,0x00,0x02,0x00,0xFE,0x3F,0x00,0x40,0x00,0x40,0x00,0x78,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x10,0x00,0x90,0x3F,0x90,0x10,0xFF,0x10,0x90,0x10,0x90,0xBF,0x10,0x40,
0x00,0x30,0xFE,0x0F,0x22,0x02,0x22,0x42,0x22,0x82,0xFE,0x7F,0x00,0x00,0x00,0x00,
0x02,0x00,0xE2,0x43,0x22,0x82,0x22,0x42,0x3E,0x3E,0x00,0x40,0x80,0x47,0x9E,0x44,
0x92,0x44,0x92,0x44,0xF2,0x7F,0x92,0x44,0x92,0x44,0x9E,0x54,0x80,0xE7,0x00,0x00,
0x40,0x00,0x50,0x00,0x4E,0x3E,0x48,0x02,0x48,0x02,0xFF,0xFF,0x48,0x12,0x48,0x22,
0x48,0x1E,0x40,0x00,0xF8,0x0F,0x00,0x40,0x00,0x80,0xFF,0x7F,0x00,0x00,0x00,0x00,
0x00,0x01,0x80,0x00,0x60,0x00,0xF8,0xFF,0x07,0x00,0x40,0x00,0x30,0x00,0x0F,0x00,
0xF8,0xFF,0x88,0x08,0x88,0x08,0x88,0x08,0x88,0x08,0x08,0x08,0x08,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0x01,0x80,0x01,0x80,0x09,0x80,0x69,0x80,0x69,0x98,0x09,0xA8,0x01,0xAB,
0x01,0xAB,0x09,0xA8,0x69,0x98,0x69,0x80,0x09,0x80,0x01,0x80,0x01,0x80,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xF0,0x07,0xF8,0x1F,0xFC,0x3F,0xFC,0x7F,0xFC,0xFF,0xF8,0xFF,0xF0,0x7F,0xEC,0x7F,
0xEE,0x7F,0xEF,0xFF,0xF7,0xFF,0xF8,0x7F,0xFC,0x7F,0x3C,0x3E,0x1C,0x1C,0x18,0x0C,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
uchar code db1[]={
0xF7,0xFD,0xF7,0xFE,0x76,0xFF,0x11,0x00,0x67,0x7F,0xFF,0xBC,0x81,0xDF,0xBD,0xE7,
0x3D,0xF8,0xBD,0xFF,0xBD,0xFF,0x3D,0xC0,0xBD,0xBF,0x81,0xBF,0xFF,0x87,0xFF,0xFF,
0xDF,0xEF,0xDF,0xF7,0xDB,0xFB,0xDB,0xFD,0xDB,0xC0,0xDB,0xBA,0x40,0xBB,0x9B,0xBB,
0xDB,0xBD,0xCB,0xBD,0xD7,0xBD,0xDB,0xBE,0xDD,0x87,0xDF,0xFF,0xDF,0xFF,0xFF,0xFF,
0x7F,0xFF,0x7F,0xFF,0xB7,0xFF,0xBB,0x80,0xD9,0x76,0xD6,0x76,0xEF,0x76,0xEF,0x70,
0xD7,0x76,0xDA,0x76,0xBD,0x76,0xBB,0x60,0x77,0x7F,0x7F,0x1F,0x7F,0xFF,0xFF,0xFF,
0xFF,0x7F,0xEF,0x7F,0xF7,0xBF,0xFB,0xBF,0x9D,0xDF,0x7E,0xEE,0xFF,0xF5,0xFF,0xFB,
0xFF,0xF5,0x7E,0xEE,0x8D,0xDF,0xFB,0xBF,0xF7,0xBF,0xEF,0x7F,0xFF,0x7F,0xFF,0xFF,
0xBF,0xFF,0xBF,0xBD,0xBB,0xDD,0xBB,0xED,0xAB,0xF5,0x9B,0xBD,0xBA,0x7D,0x39,0x80,
0xBB,0xFD,0x9B,0xFD,0xAB,0xF5,0xBB,0xED,0xBB,0xDD,0xBF,0xBD,0xBF,0xFF,0xFF,0xFF,
0xFB,0xFF,0xBB,0xFF,0xBB,0xFF,0xBB,0xFF,0xA0,0xFF,0xBB,0xFF,0x3B,0x00,0xBB,0xFF,
0xBB,0xFF,0xBB,0xF7,0xA0,0xEF,0xBB,0xF7,0x3B,0xF8,0xFB,0xFF,0xFB,0xFF,0xFF,0xFF,
0xFF,0xFE,0x1F,0xFF,0xFF,0xFF,0x00,0x00,0xEF,0xFF,0xDF,0x7E,0xF7,0xBE,0xF7,0xCE,
0xF7,0xF2,0x00,0xFC,0xF7,0xF2,0xF7,0xCE,0x07,0xBE,0xFF,0x7E,0xFF,0x7E,0xFF,0xFF,
0xFF,0xFF,0xFF,0xDF,0x1F,0xEF,0x63,0xF7,0x7B,0xF9,0x7B,0xBF,0x7B,0x7F,0x0B,0x80,
0x7D,0xFF,0x7D,0xFF,0x7C,0xFD,0x7D,0xFB,0x7F,0xF7,0x7F,0xCF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x01,0xCC,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0x7F,0xFE,0x7F,0xFE,0xFF,0x3E,0x80,0x0E,0xBE,0x2E,0xAA,0xE2,0x2E,0xEC,
0x2E,0xEC,0xAA,0xE2,0xBE,0x2E,0x80,0x0E,0xFF,0x3E,0x7F,0xFE,0x7F,0xFE,0xFF,0xFF,};
/**初始化ADC特殊功能寄存器 **/ 
void Delay(uint n) 										
{	uint x; 
	while (n--) 
	{	x = 500; 
		while (x--); 
	} 
} 
uint GetADCResult(uchar ch) 
{	ADC_CONTR = ADC_POWER | ADC_SPEEDLL | ch | ADC_START; 
	_nop_();                                        //Must wait before inquiry 
	_nop_(); 
	_nop_(); 
	_nop_(); 
	while (!(ADC_CONTR & ADC_FLAG));                //Wait complete flag 
	ADC_CONTR &= ADC_FLAG;                          //Close ADC
	return (ADC_RES*4 + ADC_RESL);                  //Return ADC result 
}
void InitADC( ) 
{	P1ASF = P1 | 0x3f;                //Set  P1.0 - P1.5 as analog input port 
	ADC_RES  = 0;                  //Clear previous result 
	ADC_RESL = 0; 
	ADC_CONTR = ADC_POWER | ADC_SPEEDLL ; 
	Delay(20);                      //ADC power-on delay and Start A/D conversion 
}
/**DelayMs()**/
void DelayMs(uint x)
{	uchar i;
	while(x--)
 	{	for (i = 0; i<87; i++);
 	}
}
/**初始化红外线接收**/
void IrInit()
{	IT0=1;//下降沿触发
	EX0=1;//打开中断0允许
	EA=1;	//打开总中断
	IRIN=1;//初始化端口
}
/**读取红外数值的中断函数**/
void ReadIr() interrupt 0
{	uchar j,k;
	uint err;
	Time=0;					 
	DelayMs(70);
	if(IRIN==0)		//确认是否真的接收到正确的信号
	{	err=1000;				//1000*10us=10ms,超过说明接收到错误的信号	
		while((IRIN==0)&&(err>0))	//等待前面9ms的低电平过去  		
		{	DelayMs(1);
			err--;
		} 
		if(IRIN==1)			//如果正确等到9ms低电平
		{	err=500;
			while((IRIN==1)&&(err>0))		 //等待4.5ms的起始高电平过去
			{	DelayMs(1);
				err--;
			}
			for(k=0;k<4;k++)		//共有4组数据
			{	for(j=0;j<8;j++)	//接收一组数据
				{	err=60;		
					while((IRIN==0)&&(err>0))//等待信号前面的560us低电平过去//while (!IRIN)
					{	DelayMs(1);
						err--;
					}
					err=500;
					while((IRIN==1)&&(err>0))	 //计算高电平的时间长度。
					{	DelayMs(1);//0.14ms
						Time++;
						err--;
						if(Time>30)
						{	EX0=1;
							return;
						}
					}
					IrValue[k]>>=1;	 //k表示第几组数据
					if(Time>=8)			//如果高电平出现大于565us,那么是1
					{	IrValue[k]|=0x80;
					}
					Time=0;		//用完时间要重新赋值							
				}
			}
		}
		if(IrValue[2]!=~IrValue[3])
		{	return;
		}
	}			
}
/** 函数名:延时函数 **/
void delayok(uchar z)
{	uint x,y;
	for(x=z;x>0;x--)
	  for(y=10;y>0;y--);
}
void delay1ms(uint z)
{ 	uint i;
	uchar j,b;
	for(i=0;i<z;i++)
	  for(j=222;j>0;j--)
	  for(b=12;b>0;b--);
}
void delaygood(uchar z)
{	uint x,y;
	for(x=z;x>0;x--)
	  for(y=780;y>0;y--);
}
/** 函数名:时钟 **/
void time0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
if(++count==20)
{
	count=0;
	seconds++;
	if (seconds==60)
	{	seconds=0;
	}
}	
}
/** 函数名:自检函数 **/
void zijian()
{	for(i=0;i<8;i++)
	{	P3=tab1[i];
		delay1ms(1000);
	}
	P3=0xff;
	for(i=0;i<8;i++)
	{	P1=tab1[i];
		delay1ms(1000);
	}
	P1=0xff;P3=0xff;
}
/** 函数名:同心圆 **/
void circle()
{	uchar k;
	for(k=0;k<1;k++)
	{
		for(i=0;i<8;i++)
		{	P1=tab[i];
			delay1ms(1000);
		}
		P1=0xff;
		for(i=0;i<8;i++)
		{	P3=tab[i];
			delay1ms(1000);
		}
		P3=0xff;
		for(i=1;i<8;i++)
		{	P3=tab1[i];
			delay1ms(1000);
		}
		P3=0xff;
		for(i=0;i<8;i++)
		{	P1=tab1[i];
			delay1ms(1000);
		}
		P1=0xff;
	}
}
/** 函数名:字符“IT” **/
void word1()
{	num = (GetADCResult(0) * 5/ 1024.0);
	if(KEY==0)
	   	{	delay1ms(10);
		     while(KEY==0);
		     for(i=0;i<16;i++)
	       	{	if(num<1.0)
				{	P1=SB1[2*i];P3=SB1[2*i+1];delayok(4);
					P1=0xff;P3=0xff;delayok(16);
				}
				else if(num<2.0)
				{	P1=SB1[2*i];P3=SB1[2*i+1];delayok(8);
					P1=0xff;P3=0xff;delayok(12);
				}
				else if(num<3.0)
				{	P1=SB1[2*i];P3=SB1[2*i+1];delayok(12);
					P1=0xff;P3=0xff;delayok(8);
				}
				else if(num<4.0)
				{	P1=SB1[2*i];P3=SB1[2*i+1];delayok(16);
					P1=0xff;P3=0xff;delayok(4);
				}
				else
				{	P1=SB1[2*i];P3=SB1[2*i+1];delayok(20);
					P1=0xff;P3=0xff;
				}
			}
			P1=0xff;P3=0xff;
		}
}
/** 函数名:字符“电” **/
void word2()
{	num = (GetADCResult(0) * 5/ 1024.0);
	if(KEY==0)
	   	{	delay1ms(10);
		     while(KEY==0);
		     for(i=0;i<16;i++)
	       	{
				if(num<1.0)
				{	P1=SB2[2*i];P3=SB2[2*i+1];delayok(4);
					P1=0xff;P3=0xff;delayok(16);
				}
				else if(num<2.0)
				{	P1=SB2[2*i];P3=SB2[2*i+1];delayok(8);
					P1=0xff;P3=0xff;delayok(12);
				}
				else if(num<3.0)
				{	P1=SB2[2*i];P3=SB2[2*i+1];delayok(12);
					P1=0xff;P3=0xff;delayok(8);
				}
				else if(num<4.0)
				{	P1=SB2[2*i];P3=SB2[2*i+1];delayok(16);
					P1=0xff;P3=0xff;delayok(4);
				}
				else
				{	P1=SB2[2*i];P3=SB2[2*i+1];delayok(20);
					P1=0xff;P3=0xff;
				}
			}
			P1=0xff;P3=0xff;
		}	
}
/** 函数名:滚动字幕 **/
void word3()
{	num = (GetADCResult(0) * 5/ 1024.0);
	if(KEY==0)
		{	j++;            
		    if(j>320)
		    {	j=0;
				P1=0xff;P3=0xff;delay1ms(2000);
		    }                
		    for(a=j;a<128+j;a++)
		    {   
				if(num<1.0)
				{	P1=~db[a*2];P3=~db[a*2+1];delayok(4);
					P1=0xff;P3=0xff;delayok(16);
				}
				else if(num<2.0)
				{	P1=~db[a*2];P3=~db[a*2+1];delayok(8);
					P1=0xff;P3=0xff;delayok(12);
				}
				else if(num<3.0)
				{	P1=~db[a*2];P3=~db[a*2+1];delayok(12);
					P1=0xff;P3=0xff;delayok(8);
				}
				else if(num<4.0)
				{	P1=~db[a*2];P3=~db[a*2+1];delayok(16);
					P1=0xff;P3=0xff;delayok(4);
				}
				else
				{	P1=~db[a*2];P3=~db[a*2+1];delayok(20);
					P1=0xff;P3=0xff;
				}
		    }
			P1=0xff;P3=0xff;
		}	
}
/** 函数名:字符“生日快乐” **/
void word4()
{	if(KEY==0)
   	{	delay1ms(10);
	    while(KEY==0);
	    for(a=0;a<160;a++)
		{	P1=db1[2*a];P3=db1[2*a+1];delayok(16);
			P1=0xff;P3=0xff;
		}
		P1=0xff;P3=0xff;
	}	
}
/** 主程序 **/
void main()
{	P1=0xff;
	P2=0xff;
	P3=0xff;
	KEY=1;
	IrInit();
	zijian();
	while(1){
		if((PB1==0)||(IrValue[2]==0X0C))
			{	delay1ms(10);
				circle();
			}
		else if((PB2==0)||(IrValue[2]==0X18))
			{	delay1ms(10);
				while(1)
				{	EX0=1;
					if(IrValue[2]==0X4A) break;
					EX0=0;
					word1();
				}
			}
		else if((PB3==0)||(IrValue[2]==0X5E))
			{	delay1ms(10);
				while(1)
				{	EX0=1;
					if(IrValue[2]==0X4A) break;
					EX0=0;
					word2();
				}
			}
		else if((PB4==0)||(IrValue[2]==0X08))
			{	delay1ms(10);
				IE=0X82;
				TMOD=0x01;
				TH0=(65536-50000)/256;
				TL0=(65536-50000)%256;
				TR0=1;
				P1=0XFF;P3=0XFF;
				while(1)
				{	EX0=1;
					if(IrValue[2]==0X4A) break;
					EX0=0;
					if(KEY==0)
				   	{	delay1ms(10);
						while(KEY==0);
						delaygood(seconds);
						for(i=0;i<5;i++)
						{
						P1=nb[2*i];P3=nb[2*i+1];delayok(30);
						P1=0xff;P3=0xff;
						}
					}
				}	  
			}
		else if(IrValue[2]==0X1C)
			{	delay1ms(10);
				while(1)
			    {	EX0=1;
					if(IrValue[2]==0X4A) break;
					EX0=0;
					word3();
			    }	  
			}
		else if(IrValue[2]==0X5A)
			{	delay1ms(10);
				while(1)
			    {	EX0=1;
					if(IrValue[2]==0X4A) break;
					EX0=0;
					word4();
			    }	  
			}
		}
}

总结:

这次比赛让我有点头疼,因为本来是三个人一组,妈蛋,其他两个人基本上全打酱油的,什么都不做。记得第二天比赛了,我跟一个同学说搞一下报告,结果他说他要自习,晚上9点多回来搞,我说你自习你昨天考完四级干啥呢,玩了一下午带一晚上dota,他又说不一样怎么怎么的,我只能呵呵呵了。后来晚上9点半他自习回来从网上下载了一篇类似的报告,随便改了一改给我了,我拿到报告发现很多错误,然后我就一直改,改到晚上一点多钟,操蛋,第二天上午比赛,他俩都去上课去了,我一个人留在宿舍继续改报告。

最后我们比赛过后东西交上去不还给我们了,到头来却是二等奖,而我的一同学用我们的霍尔传感器,没有红外遥控功能,没有滚动字幕,却拿了一等奖,当时心里却是令人不爽,但同时也让我变的更加机智不是嘛~呵呵。

本博客所有文章如无特别注明均为原创。作者:封笔尘缘复制或转载请以超链接形式注明转自 封笔尘缘
原文地址《旋转LED灯-(摇摇棒)
分享到:更多

相关推荐

网友评论(0)