From 8f306d1955e3ef33fbb2589b54feccd10841fd92 Mon Sep 17 00:00:00 2001 From: Viajero <2737079298@qq.com> Date: Thu, 29 May 2025 08:29:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20=E7=BA=A2=E5=A4=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 红外/ir_controller.ino | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 红外/ir_controller.ino diff --git a/红外/ir_controller.ino b/红外/ir_controller.ino new file mode 100644 index 0000000..ae6d097 --- /dev/null +++ b/红外/ir_controller.ino @@ -0,0 +1,40 @@ +#include "irre.h" +#include + +#define IR_RECV_PIN 18 +#define IR_SEND_PIN 19 + +// 内存预置配置(示例NEC协议32位信号) +BinHeader configHeader = { + .protocol = 0x0001, // NEC协议编码 + .bits = 32 // 32位信号 +}; +// NEC协议空调开关信号(单位:微秒) +// 协议结构: +// [引导码]9000,4500 + +// [地址码]16位 + [反码]16位 + +// [命令码]16位 + [反码]16位 + +// [结束标志]560 +uint16_t rawData[68] = { + /*-- 引导码 --*/ 9000,4500, + /*-- 地址码 0x00FF --*/ + 560,560, 560,560, 560,560, 560,560, 560,1690, 560,560, 560,560, + /*-- 地址反码 0xFF00 --*/ + 560,560, 560,1690, 560,1690, 560,560, 560,1690, 560,1690, 560,1690, 560,560, + /*-- 命令码 0x12ED --*/ + 560,560, 560,1690, 560,560, 560,560, 560,560, 560,1690, 560,560, 560,1690, + /*-- 命令反码 + 结束符 --*/ + 560,1690, 560,1690, 560,1690, 560,1690, 560,1690, 560,39756 +}; + +void setup() { + Serial.begin(115200); + while (!Serial); + Serial.println("内存配置就绪"); +} + +void loop() { + // 发送预存的红外信号 +IrSender.sendRaw(rawData, 68, 38, IR_SEND_PIN); + delay(5000); +} \ No newline at end of file