;***************************************
;遥控4按键模仿 15F104E ;内部振动11.0592M;按1就P3.0低电平,按2就P3.1低电平 按3就P3.2低电平 按4就P3.3低电平 ;蜂呜器提示, ;自学习功用,按住要学习的键2秒,;蜂呜器长响,学习成功中止响;***************************YHM EQU 2fh;用户码SET0 EQU 30H;SET1 EQU 31H;SET2 EQU 32H;SET3 EQU 33H;;;;;;;;;;;;;;;;;;;;;;;;;;IAP_DATA EQU 0C2HIAP_ADDRH EQU 0C3HIAP_ADDRL EQU 0C4HIAP_CMD EQU 0C5HIAP_TRIG EQU 0C6HIAP_CONTR EQU 0C7HENABLE_IAP EQU 83H ;体系作业时钟<12MHZ时;************************IR_KEY BIT P3.5;红外beep bit p3.3MA1 EQU 7BH ;MA2 EQU 7CH ;MA3 EQU 7DH MA4 EQU 7EH ;RED_32 EQU 7FH;;************ORG 0H ;程序开端AJMP STARTORG 30H;*************; 单片机初始化START:mov p3,#0ffh MOV DPTR, #0call EEPROMRmov 30h,ainc dptrcall EEPROMRmov 31h,ainc dptrcall EEPROMRmov 32h,ainc dptrcall EEPROMRmov 33h,aMOV DPTR, #200hcall EEPROMRmov 2fh,a;********************************MAIN:orl p3,#17hmov a,p3anl a,#17hcjne a,#17h,d2jmp d4d2:call delay2Sorl p3,#17hmov a,p3anl a,#17hcjne a,#17h,d3jmp d4d3:cpl aanl a,#17hmov 20h,aclr beepd4:jb IR_KEY,MAINACALL IRmov a,20hjnz d4AJMP MAIN ;回来;***************************IR:PUSH ACCPUSH PSWLCALL DELAY1MSLCALL DELAY1MSLCALL DELAY1MSLCALL DELAY1MSJB IR_KEY,IR_OUT;;高电平退出JNB IR_KEY,$;等 IR 变为高电平LCALL DELAY2MS380USLCALL DELAY2MS380USJB IR_KEY,IR_OUT;是否低电平MOV R0,#MA1;开端内存为7CH,共4个内存JJJ:MOV R3,#8 ;8位BBB:JNB IR_KEY,$;等 IR 变为高电平;高电平后开端计数,计数值1 高电平1MOV R2,#0 ;1MS计数CCC:LCALL DELAY1MSJNB IR_KEY,DDD ;低电平跳出计数INC R2;;高电平持续计数CJNE R2,#3,CCC;避免计数超时AJMP IR_OUTDDD:CLR ACLR CSUBB A,R2 ;MOV A,@R0RRC AMOV @R0,A ;处理完一位DJNZ R3,BBB;8位数据INC R0;换下一个内存CJNE R0,#RED_32,JJJ ;写完个4内存;4个8位码存入MA1~MA4中;-------------------------------------MOV A,MA4CPL ACJNE A,MA3,IR_OUTjbc 0,s30jbc 1,s31jbc 2,s32jbc 4,s33MOV A,MA2;CJNE A,YHM,IR_OUT;CALL IR_GOTOIR_OUT:POP PSWPOP ACCRETs30:mov set0,MA3call bao0call bao1setb beepjmp IR_OUTs31:mov set1,MA3call bao0call bao1setb beepjmp IR_OUTs32:mov set2,MA3call bao0call bao1setb beepjmp IR_OUTs33:mov set3,MA3call bao0call bao1setb beepjmp IR_OUT;----------------IR_GOTO:mov a,ma3