108个传感器之-红外接收模块(9)

108个传感器之-红外接收模块(9)

介绍

该模块可以接收红外信号,并将其转换为输出端发出的数字信号。当检测到红外信号时,模块上的集成LED会短暂闪烁,提供信号接收的视觉确认。它非常适合使用红外遥控器或其他红外信号的项目。由于其简单的操作和可靠的信号处理,该模块可以很容易地集成到各种电子项目中,例如实现远程控制或无线传输数据。

Technical Data
Operating voltage 3,3 V - 5 V
Operating current 0,4 - 1,5 mA
Reception range 18 m

引脚连接

在PCB上,可以直接焊接所需的电阻器。焊接电阻器的位置位于PCB上连接引脚的正上方。

示例图

pin 引脚连接开发板的 gpio 接口即可:

DEV BOARD Sensor
Pin 10 Signal
5 V +V
GND GND

代码示例

在两个传感器模块的帮助下,KY-005和KY-022可以构建具有红外遥控器和红外接收器的系统。为此,除两个模块外,还需要两个Arduinos。然后,这些充当信号的发射机和接收器。

借助传感器模块KY-022,可以构建红外接收器。为此,只需要红外接收器模块和一个单一的arduino。Arduino充当接收器,并将信号输出到串行控制台。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <Arduino.h>
#include "PinDefinitionsAndMore.h"
#include <IRremote.hpp>
/*
* Specify which protocol(s) should be used for decoding.
* If no protocol is defined, all protocols (except Bang&Olufsen) are active.
* This must be done before the #include <IRremote.hpp>.
*/
//#define DECODE_DENON // Includes Sharp
//#define DECODE_JVC
//#define DECODE_KASEIKYO
//#define DECODE_PANASONIC // Alias for DECODE_KASEIKYO
//#define DECODE_LG
#define DECODE_NEC // Includes Apple and Onkyo. To enable all protocols, simply comment/uncomment this line.
//#define DECODE_SAMSUNG
//#define DECODE_SONY
//#define DECODE_RC5
//#define DECODE_RC6
//#define DECODE_BOSEWAVE
//#define DECODE_LEGO_PF
//#define DECODE_MAGIQUEST
//#define DECODE_WHYNTER
//#define DECODE_FAST
//#define DECODE_DISTANCE_WIDTH // Universal decoder for pulse distance protocols
//#define DECODE_HASH // special decoder for all protocols
//#define DECODE_BEO // This protocol must always be activated manually, i.e. it is NOT activated if no protocol is defined. It prevents the decoding of SONY!

//#define DEBUG // Enable this to get lots of nice debug output from the decoders.
//#define RAW_BUFFER_LENGTH 750 // 750 is required for remote controls for air conditioning systems. Standard is 200.

void setup() {
Serial.begin(115200);
while (!Serial)
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
Serial.println(F("KY-022: Infrared receiver test"));
Serial.print(F("Ready to receive IR signals from protocols: "));
printActiveIRProtocols(&Serial);
Serial.println(F("at the pin " STR(IR_RECEIVE_PIN)));
}

void loop() {
if (IrReceiver.decode()) {
if (IrReceiver.decodedIRData.protocol == UNKNOWN) {
Serial.println(F("Received noise or an unknown (or not yet activated) protocol"));
IrReceiver.printIRResultRawFormatted(&Serial, true);
IrReceiver.resume();
}
else {
IrReceiver.resume();
IrReceiver.printIRResultShort(&Serial);
}
}
}

小结

待完善…

108个传感器之-红外接收模块(9)

http://blog.jzxer.cn/20241218/20241219-reciver-ky022/

作者

dev

发布于

2024-12-18

更新于

2025-01-13

许可协议

评论

Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×