1、红外遥控调速风扇,组员:,李国平,张少华,宋尚师,红外遥控调速风扇,原理: 根据 红外遥控控制电风扇,利用数码管显示风扇转速档位。从而达到红外遥控智能风扇的效果。,调试程序:,#include void delay(int i) int j;while(i-)for(j=0;j82;j+); ,调试程序:,main() while(1)P3=0xff;P2=0xff;P1=0xff;delay(3000);P1=0x00;P2=0x00;P3=0x00;delay(3000); ,原理图,PCB,#include typedef unsigned char u8; typedef unsign
2、ed int u16; #define success 1 #define fail 0 sbit IrPort = P33; sbit dong =P37; u8 IrData4=0,0,0,0; /u8 table =0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90; u8 table =0x09,0x6f,0x1a,0x4a,0x6c,0xc8,0xda,0xda,0xda,0xda; /*延时子函数*/ void DelayNms(u16 n)/12MHz晶振,约延时n*1ms unsigned int i;while(n-) for(
3、i=0;i82;i+); /*延时883us函数*/ void Delay883us(void) unsigned char i;for(i=0;i250;i+);for(i=0;i42;i+); /*延时2400us函数*/ void Delay2400us(void) unsigned int i;,程序,for(i=0;i1)|0x80;,程序,elseIrDatai = (IrDatai1);return success;else return fail; /*中断子函数以及数码管显示*/ void Int1(void) interrupt 2 Ir_Receive();P1=tabl
4、eIrData2;P2=0x00; /*风扇转速控制子函数*/ void zhs(void) double i;switch(IrData2)case 0 : dong = 1; break;case 1 : dong = 1;for(i=0;i=200;i+);dong = 0;for(i=0;i=100;i+);break;case 2 : dong =1 ;for(i=0;i=100;i+);,程序,dong =0 ;for(i=0;i=100;i+);break;case 3 : dong =1 ;for(i=0;i=10;i+);dong =0 ;for(i=0;i=100;i+);break;case 4 : dong =1 ;for(i=0;i=1;i+);dong =0 ;for(i=0;i=100;i+);break; case 5 : dong =1 ;for(i=0;i=1;i+);dong =0 ;for(i=0;i=1000;i+);break; default : break; /*主函数以及中断初始化函数*/ main() EA = 1;EX1 = 1;IT1 = 1;while(1)P1=tableIrData2;P2=0x00;zhs(); ,End,谢 谢,