辜渝傧

13037102709

027-87870986

教学实训

您当前的位置:首页 > 教学资源 > 实训方案 >

无线传感网络实训|实验3.5 红外接收实验

发布者:唯众    布时间:2020-11-27 15:45:08    点击量:

1.实验目的

1)、通过实验掌握CC2530芯片GPIO的配置方法
2)、掌握GPIO模拟红外解码,实现接收红外遥控器的功能

2.实验设备

硬件:PC机1台、ZIGBEE节点板1套(底板、核心板、仿真器、USB 线)、唯众红外收发模块1个、红外遥控器1个
软件:2000/XP/win7 系统,IAR 8.10 集成开发环境

3.实验相关电路图

实验3.5 红外接收实验

4.实验相关寄存器

5.源码分析

#include "Delay.h"
#include "OLED.h"
 
 
#include "IRDecod.h"
#include <stdio.h>
 
 
uint8  Recdata[30]="红外解码测试\r\n";  //串口输出字符串
uint16 stringlen;                                    //字符串长度
 
extern uint16 HWAddcode,HWComcode;           //红外解码 地址码 指令码全局调用 IRDecod.c
 
 
void main(void)
{     
       unsigned char str[40];      
       uint8 j = 0;
      
       IRInit();                                            //红外接收初始化
      
       oled_port_init();
       initial_lcd(); 
      
       clear_screen();                                       //清屏
       display_string_8x16_16x16(1,1,"武汉唯众智创科技");                                                 
       display_string_8x16_16x16(3,1,"有限公司荣耀创造");
       Delay_ms(100);
       clear_screen();
      
       while(1)
       {
              if(IR_IRQ==0)                                  //如果红外接收头有信号
              {
                     j = IR_Decoding();                    //开始解码
                     if(j==0)
                     {
                            sprintf((char *)str, "A:%04X C:%04X", HWAddcode,HWComcode);
                            clear_screen();
                            display_string_8x16_16x16(1,1,str);
                            display_string_8x16_16x16(3,1,"N:");
                            switch(HWComcode)        //判断指令
                            {
                                   case 0x1234:
                                          display_string_8x16_16x16(3,16,"CH-     ");
                                          break;                               
                                   case 0xBA45:
                                          display_string_8x16_16x16(3,16,"CH-     ");
                                          break;
                                   case 0xB946:
                                          display_string_8x16_16x16(3,16,"CH      ");
                                          break;
                                   case 0xB847:
                                          display_string_8x16_16x16(3,16,"CH+     ");
                                          break;
                                   case 0xBB44:
                                          display_string_8x16_16x16(3,16,"PREV    ");
                                          break;
                                   case 0xBF40:
                                          display_string_8x16_16x16(3,16,"NEXT    ");
                                          break;
                                   case 0xBC43:
                                          display_string_8x16_16x16(3,16,"PLAY    ");
                                          break;
                                   case 0xF807:
                                          display_string_8x16_16x16(3,16,"VOL-    ");
                                          break;
                                   case 0xEA15:
                                          display_string_8x16_16x16(3,16,"VOL+    ");
                                          break;
                                   case 0xF609:
                                          display_string_8x16_16x16(3,16,"EQ      ");
                                          break;
                                   case 0xE916:
                                          display_string_8x16_16x16(3,16,"0       ");
                                          break;
                                   case 0xE619:
                                          display_string_8x16_16x16(3,16,"100+    ");
                                          break;
                                   case 0xF20D:
                                          display_string_8x16_16x16(3,16,"200+    ");
                                   break;
                                   case 0xF30C:
                                          display_string_8x16_16x16(3,16,"1       ");
                                          break;
                                   case 0xE718:
                                          display_string_8x16_16x16(3,16,"2       ");
                                          break;
                                   case 0xA15E:
                                          display_string_8x16_16x16(3,16,"3       ");
                                          break;
                                   case 0xF708:
                                          display_string_8x16_16x16(3,16,"4       ");
                                          break;
                                   case 0xE31C:
                                          display_string_8x16_16x16(3,16,"5       ");
                                          break;
                                   case 0xA55A:
                                          display_string_8x16_16x16(3,16,"6       ");
                                          break;   
                                   case 0xBD42:
                                          display_string_8x16_16x16(3,16,"7       ");
                                          break;
                                   case 0xAD52:
                                          display_string_8x16_16x16(3,16,"8       ");
                                          break;
                                   case 0xB54A:
                                          display_string_8x16_16x16(3,16,"9       ");
                                          break;                                             
                                   default:
                                          display_string_8x16_16x16(3,16,"CodError");
                                          break;
                            }
                           
                     }
              }
       }
}

6.实验现象

       使用配套的红外遥控器,对着红外收发模块按键,蓝色OLED显示屏上将显示按键的引导码、键值和按键名称。如果没有遥控器的话可以结合上一实验使用两个节点板和2个红外收发模块,做此实验。右边的模块下的是上一实验的程序,作为发送端;左边的是本实验的程序,作为接收端。当按下右边节点板的按键时,左边的接收到信号并解析成功。如图所示:
实验3.5 红外接收实验


上一篇:无线传感网络实训|实验3.4 红外发送实验

下一篇:无线传感网络实训|实验3.6 数字量传感器实验