资源描述:
《51单片机格力空调遥控器.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、.1.//51单片机格力空调遥控器2.3.#include 4.#include5.#defineucharunsignedchar6.#defineuint unsignedint 7.#defineenTransmitt flag=18.#definedisTransmitt flag=09.sfr T2MOD =0XC9;10.bit flag=0;11.sbitIR38k=P2^3; //红外发射管12.sbitkey1=P1^1;13.sbitkey2=P1^3;14.sbitkey3=P1^5;15.sbitkey4=P
2、1^7;16.sbitkey5=P1^0;17.sbitkey6=P1^4;18.ucharKeyScan();19.uint count=0,set_count=0;20.ucharfengliang_value=0;21.ucharkey_value=0;22.ucharwendu_value=0;23.ucharmode_value=0;24.ucharswitch_value=0;25.ucharzhuanye_value=0;26.ucharcodezhuanye[][5]={{0x39,0x04,0x00,0x50,0x02},{0x79,0x04,0x00,0x50,0x0
3、2}}; //手动,自动转页(20度,冷气)27.ucharcode fengliang[][5]={{0x28,0x08,0x00,0x50,0x02},{0x19,0x08,0x00,0x50,0x02},28. {0x09,0x08,0x00,0x50,0x02} 29. };//自动模式风量小,中,大 (20度)..1.ucharcode mode[][5]={ 2. {0x58,0x00,0x00,0x50,0x02},{0x59,0x04,0x00,0x50,0x02},3. {0x5
4、a,0x04,0x00,0x50,0x02},{0x5b,0x04,0x00,0x50,0x02}4. }; //自动,冷气,除湿,送风5./*ucharcode on_or_off[][5]={{0x40,0x00,0x00,0x50,0x02},{0x48,0x00,0x00,0x50,0x02}};*/6.ucharcode on_or_off[][5]={7. {0x39,0x08,0x00,0x50,0x02},{0x31,0x08,0x00,0x50,0x02}, 8. {0x59,0x08,0x00,0x
5、50,0x02},{0x51,0x08,0x00,0x50,0x02},9. {0x79,0x08,0x00,0x50,0x02},{0x71,0x08,0x00,0x50,0x02}, 10. };//开机,关机11.ucharcode wendu[][5]={12. {0x59,0x00,0x00,0x50,0x02},{0x59,0x01,0x00,0x50,0x02},13. {0x59,0x02,0x00,0x50,0x02},{0x59,0x03,0x00,0x50,0x02},14. {0x59,0x04,0x00,
6、0x50,0x02},{0x59,0x05,0x00,0x50,0x02},15. {0x59,0x06,0x00,0x50,0x02},{0x59,0x07,0x00,0x50,0x02},16. {0x59,0x08,0x00,0x50,0x02},{0x59,0x09,0x00,0x50,0x02},17. {0x59,0x0a,0x00,0x50,0x02},{0x59,0x0b,0x00,0x50,0x02},18. {0x59,0x0c,0x00,0x50,0x02},{0x59,0x0d,0x00,0x50,0x02},19.
7、 {0x59,0x0e,0x00,0x50,0x02} 20. };//温度值 21.22.voidsend_precode(unsignedints_cnt_1,unsignedints_cnt_2);23.voidsend_8bit_code(ucharvalue);24.voidsend_4bit_code(ucharvalue);25.voidsend_final_code();2