2、其次按住麻将机B键不放,让仪器来自动识别所在的位置再放手。
3、最后待遥控和麻将机闪的灯都长亮后。
#include\x0d\x0a#include\x0d\x0a#define uchar unsigned char\x0d\x0a#define uint unsigned int\x0d\x0asbit lcden = P2^7\x0d\x0asbit lcdrs = P2^6\x0d\x0asbit lcdwr = P2^5\x0d\x0asbit IR = P3^2\x0d\x0auchar IRCOM[6]//数组,用于存储红外编码\x0d\x0auchar code table1[] = "remote control"\x0d\x0auchar code table2[] = "CODE:"\x0d\x0avoid delayms(uchar x)// 延时x*0.14ms\x0d\x0a{\x0d\x0auchar i\x0d\x0awhile(x--)\x0d\x0afor(i=0i//延时xms\x0d\x0a{\x0d\x0auchar i,j\x0d\x0afor(i=xi>0i--)\x0d\x0afor(j=110j>0j--)\x0d\x0a}\x0d\x0a/****************************LCD部分***********************************************/\x0d\x0avoid write_com(uchar com)\x0d\x0a{\x0d\x0alcden = 0\x0d\x0alcdrs = 0\x0d\x0alcdwr = 0\x0d\x0aP0 = com\x0d\x0adelay(5)\x0d\x0alcden = 1\x0d\x0adelay(5)\x0d\x0alcden = 0//别忘了lcden拉低\x0d\x0a}\x0d\x0avoid write_date(uchar date)\x0d\x0a{\x0d\x0alcden = 0\x0d\x0alcdrs = 1\x0d\x0alcdwr = 0\x0d\x0aP0 = date\x0d\x0adelay(5)\x0d\x0alcden = 1\x0d\x0adelay(5)\x0d\x0alcden = 0\x0d\x0a}\x0d\x0avoid lcd_init(void)\x0d\x0a{\x0d\x0alcden = 0\x0d\x0alcdrs = 0\x0d\x0alcdwr = 0\x0d\x0adelay(5)\x0d\x0awrite_com(0x38)\x0d\x0awrite_com(0x0c)\x0d\x0awrite_com(0x06)\x0d\x0awrite_com(0x01)\x0d\x0a}\x0d\x0a/*****************main()************************/\x0d\x0avoid main(void)\x0d\x0a{\x0d\x0auchar count=0\x0d\x0aIR = 1\x0d\x0alcd_init()\x0d\x0awrite_com(0x80)\x0d\x0awhile(table1[count]!='\0')\x0d\x0a{\x0d\x0awrite_date(table1[count])\x0d\x0acount++\x0d\x0adelay(5)\x0d\x0a}\x0d\x0acount = 0\x0d\x0awrite_com(0x80+0x40)\x0d\x0awhile(table2[count]!='\0')\x0d\x0a{\x0d\x0awrite_date(table2[count])\x0d\x0acount++\x0d\x0adelay(5)\x0d\x0a}\x0d\x0a\x0d\x0aIE = 0x81//开中断\x0d\x0aTCON = 0x01//脉冲负边沿触发\x0d\x0awhile(1)\x0d\x0a\x0d\x0a}\x0d\x0a/*********************红外中断**************************/\x0d\x0avoid IR_time() interrupt 0 \x0d\x0a{\x0d\x0auchar i,j,TimeNum=0//TimeNum用来计IR高电平次数 从而判断是0还是1\x0d\x0aEX0 = 0//关闭中断\x0d\x0adelayms(5)\x0d\x0aif(1 == IR)\x0d\x0a{\x0d\x0aEX0 = 1\x0d\x0areturn\x0d\x0a}\x0d\x0awhile(!IR) //跳过9ms前导低电平\x0d\x0adelayms(1)\x0d\x0afor(i=0i{\x0d\x0afor(j=0j{\x0d\x0awhile(IR) //跳过4.5ms的前导高电平\x0d\x0adelayms(1)\x0d\x0awhile(!IR) //跳过0.56ms的低电平\x0d\x0adelayms(1)\x0d\x0a\x0d\x0awhile(IR) \x0d\x0a{\x0d\x0aTimeNum++//计时高电平时间从而判断读取的是0还是1\x0d\x0adelayms(1)\x0d\x0a}\x0d\x0aif(TimeNum>=30)//按键按下时间过长 跳过\x0d\x0a{\x0d\x0aEX0 = 1\x0d\x0areturn\x0d\x0a}\x0d\x0aIRCOM[i] = IRCOM[i]>>1\x0d\x0aif(TimeNum >= 8) //8*0.14ms 这时读取的是1;\x0d\x0a{\x0d\x0aIRCOM[i] = IRCOM[i]|0x80\x0d\x0a}\x0d\x0aTimeNum = 0\x0d\x0a}\x0d\x0a}\x0d\x0aif(IRCOM[2]!=~IRCOM[3])//判断八位数据和八位数据反码是否相等\x0d\x0a{\x0d\x0aEX0 = 1\x0d\x0areturn\x0d\x0a}\x0d\x0aIRCOM[4] = IRCOM[2]&0x0f//取低四位\x0d\x0aIRCOM[5] = IRCOM[2]>>4//IRCOM[5]取IRCOM[2]高四位\x0d\x0aif(IRCOM[4] >9) //转换成字符\x0d\x0a{\x0d\x0aIRCOM[4] = IRCOM[4] + 0x37\x0d\x0a}\x0d\x0aelse\x0d\x0aIRCOM[4] = IRCOM[4] + 0x30\x0d\x0aif(IRCOM[5] >9)\x0d\x0a{\x0d\x0aIRCOM[5] = IRCOM[5] + 0x37\x0d\x0a}\x0d\x0aelse\x0d\x0aIRCOM[5] = IRCOM[5] + 0x30\x0d\x0adelay(5)\x0d\x0awrite_com(0x80 + 0x40 + 5)\x0d\x0awrite_date(IRCOM[5])\x0d\x0awrite_date(IRCOM[4])\x0d\x0aEX0 = 1//重新开启外部中断\x0d\x0a}手机遥控空调方法如下:方法一、在桌面找到智慧生活进入--登录vivo帐号后选择智能遥控--点击右上角“+”号添加空调设备遥控器,然后点击已添加的空调设备遥控器进入即可遥控该空调,若需要经常使用该设备可选择相应的遥控器长按,选择下方“桌面快捷”,可手动添加快捷方式到桌面(适用红外遥控机型);
方法二、通过智慧生活进行控制:开启手机蓝牙,进入“智慧生活”--首页--添加设备--扫描设备后点击连接,或者点击该页面右上角扫描包装盒上的二维码连接,连接成功后即可进行遥控;
方法三、使用手机下载空调对应的APP软件,然后将手机和空调连接在同一个局域网上,即可实现手机遥控空调。
划重点:需要看空调是否支持该功能,请详见空调说明书。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)