1、/* 描述: * */#include #include #define uchar unsigned char#define uint unsigned intuchar LCD_ID_116 = “Red Control“;uchar LCD_ID_216 = “IR CODE:-H“;void delay(uchar x); /x*0.14MSvoid delay1(int ms);void beep();sbit IRIN = P33; /红外接收器数据线sbit BEEP = P15; /蜂鸣器驱动线sbit RELAY= P14; /继电器驱动线uchar IRCOM7;sbit
2、E=P27; /1602使能引脚sbit RW=P26; /1602读写引脚sbit RS=P25; /1602数据/命令选择引脚/* 名称 : delay()* 功能 : 延时,延时时间大概为 140US。* 输入 : 无* 输出 : 无*/void Delay2()int i,j;for(i=0; i=30) EX1=1;return; /0.14ms计数过长自动离开。 /高电平计数完毕 IRCOMj=IRCOMj 1; /数据最高位补“0”if (N=8) IRCOMj = IRCOMj | 0x80; /数据最高位补“1”N=0;/end for k/end for jif (IRCO
3、M2!=IRCOM3) EX1=1;return; IRCOM5=IRCOM2 /取键码的低四位IRCOM6=IRCOM2 4; /右移 4次,高四位变为低四位if(IRCOM59) IRCOM5=IRCOM5+0x37;elseIRCOM5=IRCOM5+0x30;if(IRCOM69) IRCOM6=IRCOM6+0x37;elseIRCOM6=IRCOM6+0x30;/L1602_char(2,10,IRCOM5);L1602_char(2,9,IRCOM6);/beep();EX1 = 1; /*/void beep()unsigned char i;for (i=0;i100;i+)delay(4);BEEP=!BEEP; /BEEP取反 BEEP=1; /关闭蜂鸣器/*/void delay(unsigned char x) /x*0.14MSunsigned char i;while(x-)for (i = 0; i13; i+) /*/void delay1(int ms)unsigned char y;while(ms-)for(y = 0; y250; y+)_nop_();_nop_();_nop_();_nop_();