单片机解密433和315无线模块的软件编解码遥控程序
单片机解密433和315无线模块的软件编解码遥控程序 1:单片机软件解码PT2240 2:选用PIC16F877A作为软件解码芯片 3:单片机时钟频率选用外部4MHZ晶振 4:选用外部中断脚作为编码信号脚输入脚 5:可解PT2240芯片(8脚的学习型编码芯片 编码地址位:2的20次方 重复几率100万分之一) 6:功能有:遥控器学习(DEMO上的S9作为学习按纽) 清除记忆(长按DEMO上的S9即可清除遥控器 地址的记忆) 7:学习遥控器数量可以设定(可根据EEPROM的大小 随便设定) 8:输出功能(有三路是 单击遥控器双稳,可以通过PORTC上的LED可以看到结果.还有一路是 双击遥控器双稳) 9:可选用315MHZ/433MHZ的超再生/超外差接收模块 /******************************************************************************/ /****************************** 遥控器接收程序 ********************************/ /******************************************************************************/ #include <pic.h> #include <pic1687x.h> #define remote_geshu 10 /******************************************************************************/ union BIT_16 { int TIMER1_REG; unsigned char REG[2]; } union BIT_32 { unsigned long data_temp_long; unsigned char data_temp_byte[4]; } /******************************************************************************/ static union BIT_16 TIMER1_TEMP;//16位定时器1 static union BIT_32 data_temp; /******************************************************************************/ static volatile unsigned char rec_status @ 97; static unsigned char data_cout;//接收的遥控器码位数 static unsigned char data;//接收的4位数据 static unsigned int h_pulse;//高电平宽度 static unsigned int l_pulse;//低电平宽度 static unsigned char remote_cout;//遥控器数量 static unsigned char remote_numb;//遥控器编号 /******************************************************************************/ static unsigned char TIMER15S1;//清除学习码按键长按时间 static unsigned char TIMER15S2;//学习等待时间 static unsigned char TIMER15S3;//遥控器数据缓冲时间 static unsigned char TIMER15S4;//LED显示时间 static unsigned char TIMER15S5;// static unsigned char TIMER15S6;// static unsigned char TIMER15S7;// static unsigned char TIMER15S8;// /******************************************************************************/ static bit head @ ((unsigned)(&rec_status)*8+(0));//同步头标志位 static bit learn @ ((unsigned)(&rec_status)*8+(1));//学习标志位 static bit recieved @((unsigned)(&rec_status)*8+(2));//接收完成标志位 static bit remote_button_status @((unsigned)(&rec_status)*8+(3));//遥控器按键标志位 static bit first_click_status @((unsigned)(&rec_status)*8+(4));//遥控器按键单击标志位 |