[参考]一种灯光遥控器的红外参数

image
搜索关键词:红外 LED 吸顶灯 遥控器 变色 智能 灯 具 无极调光 灯泡遥控手柄

这种遥控器的结构较为简单,其中含有一个不含识别码的记忆模块TL HW12(拆开壳就看得到了),因此可以通过接收器完全获取其中的按键发送的红外数据。在这里我使用了arduino进行截取,获取了以下的红外信号数据。所有信号都已经对应图进行了标注。
下属数据截止本文发布时实测有效

private int[] rawData_nightlight = {8730,4420, 530,570, 530,570, 530,570, 480,620, 480,570, 530,570, 530,570, 530,1620, 530,1670, 480,1670, 530,1620, 530,1620, 530,1670, 480,1670, 530,1620, 530,570, 530,1620, 530,570, 530,1620, 530,570, 530,570, 530,570, 530,520, 530,620, 480,620, 480,1670, 480,620, 480,1670, 480,1670, 530,1620, 530,1670, 480,1620, 530};  		
private int[] rawData_On = {8730,4420, 480,570, 530,570, 530,570, 530,570, 480,620, 480,620, 480,570, 530,1670, 480,1670, 530,1620, 530,1620, 530,1670, 480,1670, 530,1620, 530,1620, 530,570, 530,1670, 480,570, 530,570, 530,570, 530,570, 480,620, 480,620, 480,570, 530,570, 530,1620, 530,1670, 480,1670, 530,1620, 530,1620, 530,1670, 480,1670, 530};  				
private int[] rawData_Off = {8730,4420, 530,570, 480,620, 480,620, 480,570, 530,570, 530,570, 530,570, 480,1670, 530,1620, 530,1670, 480,1670, 530,1620, 530,1620, 530,1670, 480,1670, 530,570, 480,1670, 530,570, 530,570, 480,620, 480,570, 530,570, 530,570, 530,570, 530,570, 480,1670, 530,1620, 530,1620, 530,1670, 480,1670, 530,1620, 530,1670, 480};  				
private int[] rawData_arrow_up = {8730,4420, 480,570, 530,570, 530,570, 530,570, 530,570, 530,570, 480,620, 480,1670, 480,1670, 530,1620, 530,1670, 480,1670, 530,1620, 530,1620, 530,1670, 480,620, 480,570, 530,1670, 480,620, 480,570, 530,1670, 480,570, 530,570, 530,570, 530,1620, 530,570, 530,1670, 480,1670, 480,620, 480,1670, 530,1620, 530,1620, 530};  		
private int[] rawData_arrow_left = {8730,4420, 530,570, 530,570, 480,620, 480,570, 530,570, 530,570, 530,570, 530,1620, 530,1620, 530,1670, 480,1670, 530,1620, 530,1620, 530,1670, 480,1670, 530,570, 480,620, 480,1670, 530,1620, 530,1620, 530,1670, 480,620, 480,570, 530,570, 530,1670, 480,570, 530,570, 530,570, 530,570, 480,1670, 530,1620, 530,1670, 480};  		
private int[] rawData_lightness = {8730,4370, 530,620, 480,570, 530,570, 530,570, 530,570, 530,570, 480,620, 480,1670, 480,1670, 530,1620, 530,1670, 480,1670, 530,1620, 530,1620, 530,1670, 480,620, 480,1670, 480,1670, 530,1620, 530,1670, 480,1620, 580,1620, 530,1620, 530,1670, 480,620, 480,570, 530,570, 530,570, 530,570, 480,620, 480,620, 480,570, 530};  		
private int[] rawData_arrow_right = {8730,4420, 480,620, 480,570, 530,570, 530,570, 530,570, 530,570, 480,620, 480,1670, 480,1670, 530,1620, 530,1620, 530,1670, 530,1620, 530,1620, 530,1670, 480,620, 480,570, 530,1670, 480,620, 480,570, 530,1670, 480,570, 530,570, 530,570, 530,1620, 530,570, 530,1670, 480,1670, 480,620, 480,1670, 480,1670, 530,1620, 530};  		
private int[] rawData_arrow_down = {8780,4370, 530,570, 530,570, 530,570, 530,570, 480,620, 480,570, 530,570, 530,1670, 480,1670, 480,1670, 530,1620, 530,1670, 480,1670, 480,1670, 530,1620, 530,570, 530,570, 530,1620, 530,1670, 480,1670, 530,1620, 530,570, 530,570, 480,620, 480,1670, 530,570, 480,620, 480,570, 530,570, 530,1670, 480,1670, 480,1670, 530};  		
private int[] rawData_auxiliary1 = {8730,4420, 530,570, 530,570, 530,570, 480,620, 480,570, 530,570, 530,570, 530,1620, 530,1620, 530,1670, 480,1670, 530,1620, 530,1670, 480,1670, 530,1620, 530,570, 530,570, 530,1620, 530,570, 530,1620, 530,1670, 480,570, 530,570, 530,570, 530,1620, 530,570, 530,1620, 530,570, 530,570, 530,1620, 530,1670, 480,1670, 480};  		
private int[] rawData_auxiliary2 = {8730,4370, 530,620, 480,570, 530,570, 530,570, 530,570, 480,620, 480,620, 480,1670, 480,1670, 530,1620, 530,1670, 480,1670, 480,1670, 530,1620, 530,1670, 480,570, 530,570, 530,1670, 480,570, 530,1670, 480,1670, 480,620, 480,620, 480,570, 530,1670, 480,570, 530,1670, 480,620, 480,570, 530,1670, 480,1670, 530,1620, 530};  		
private int[] rawData_auxiliary3 = {8730,4420, 530,570, 530,570, 530,570, 530,570, 480,620, 480,570, 530,570, 530,1670, 480,1670, 480,1670, 530,1620, 530,1670, 480,1670, 480,1670, 530,1620, 530,570, 530,570, 530,1620, 530,570, 530,1670, 480,1670, 480,620, 480,570, 530,570, 530,1670, 480,570, 530,1670, 480,620, 480,570, 530,1670, 480,1670, 530,1620, 530};  		
private int[] rawData_warmth_decrease = {8730,4420, 530,570, 530,570, 480,620, 480,620, 480,570, 530,570, 530,570, 530,1620, 530,1670, 480,1670, 480,1670, 530,1620, 530,1670, 480,1670, 530,1620, 530,570, 530,1620, 530,1670, 480,570, 530,570, 530,570, 530,570, 530,570, 480,620, 480,620, 480,570, 530,1670, 480,1670, 480,1670, 530,1620, 530,1670, 480,1670, 480};  	
private int[] rawData_warmth_increase = {8730,4370, 530,620, 480,570, 530,570, 530,570, 530,570, 530,570, 480,620, 480,1670, 480,1670, 530,1620, 530,1670, 480,1670, 530,1620, 530,1620, 530,1670, 480,620, 480,570, 530,1670, 480,620, 530,520, 530,570, 530,570, 530,570, 530,570, 480,1670, 530,570, 480,1670, 530,1620, 530,1670, 480,1670, 530,1620, 530,1620, 530};  	
private int[] rawData_segment = {8730,4420, 480,570, 530,570, 530,570, 530,570, 480,620, 480,570, 530,570, 530,1670, 480,1670, 480,1670, 530,1620, 530,1670, 480,1670, 480,1670, 530,1620, 530,570, 530,570, 530,1620, 530,1670, 480,570, 530,570, 530,570, 530,570, 480,620, 480,1670, 530,570, 480,620, 480,1670, 480,1670, 530,1620, 530,1670, 480,1670, 480};  			

可以通过上述红外信号设计一个红外发射app,用于取代遥控器。
详见 我创建的Github项目,其中已经发布了一个可用的版本。


另附:ardiuno接收红外信号(使用VS1838B)的示例代码(来源于公开的红外库)

所收取的数据就是rawdata段

/*
 * ReceiveDump.cpp
 *
 * Dumps the received signal in different flavors.
 * Since the printing takes so much time, repeat signals may be skipped or interpreted as UNKNOWN.
 *
 *  This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
 *
 ************************************************************************************
 * MIT License
 *
 * Copyright (c) 2020-2021 Armin Joachimsmeyer
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is furnished
 * to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 ************************************************************************************
 */
#include <Arduino.h>

//#define RAW_BUFFER_LENGTH  750  // 750 is the value for air condition remotes.

/*
 * Define macros for input and output pin etc.
 */
#include "PinDefinitionsAndMore.h"

/*
 * You can change this value accordingly to the receiver module you use.
 * The required value can be derived from the timings printed here.
 * Keep in mind that the timings may change with the distance
 * between sender and receiver as well as with the ambient light intensity.
 */
#define MARK_EXCESS_MICROS    20 // recommended for the cheap VS1838 modules

//#define RECORD_GAP_MICROS 12000 // Activate it for some LG air conditioner protocols
//#define DEBUG // Activate this for lots of lovely debug output from the decoders.
#define INFO // To see valuable informations from universal decoder for pulse width or pulse distance protocols

#include <IRremote.hpp>

//+=============================================================================
// Configure the Arduino
//
void setup() {
    pinMode(LED_BUILTIN, OUTPUT);

    Serial.begin(115200);   // Status message will be sent to PC at 9600 baud
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL)  || defined(ARDUINO_attiny3217)
    delay(4000); // To be able to connect Serial monitor after reset or power up and before first print out. Do not wait for an attached Serial Monitor!
#endif
    // Just to know which program is running on my Arduino
    Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));

    IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK); // Start the receiver, enable feedback LED, take LED feedback pin from the internal boards definition

    Serial.print(F("Ready to receive IR signals of protocols: "));
    printActiveIRProtocols(&Serial);
    Serial.print(F("at pin "));
    Serial.println(IR_RECEIVE_PIN);
}

//+=============================================================================
// The repeating section of the code
//
void loop() {
    if (IrReceiver.decode()) {  // Grab an IR code
        // Check if the buffer overflowed
        if (IrReceiver.decodedIRData.flags & IRDATA_FLAGS_WAS_OVERFLOW) {
            Serial.println(F("Overflow detected"));
            Serial.println(F("Try to increase the \"RAW_BUFFER_LENGTH\" value of " STR(RAW_BUFFER_LENGTH) " in " __FILE__));
            // see also https://github.com/Arduino-IRremote/Arduino-IRremote#modifying-compile-options-with-sloeber-ide
        } else {
            Serial.println();                               // 2 blank lines between entries
            Serial.println();
            IrReceiver.printIRResultShort(&Serial);
            Serial.println();
            Serial.println(F("Raw result in internal ticks (50 us) - with leading gap"));
            IrReceiver.printIRResultRawFormatted(&Serial, false); // Output the results in RAW format
            Serial.println(F("Raw result in microseconds - with leading gap"));
            IrReceiver.printIRResultRawFormatted(&Serial, true);  // Output the results in RAW format
            Serial.println();                               // blank line between entries
            Serial.print(F("Result as internal ticks (50 us) array - compensated with MARK_EXCESS_MICROS="));
            Serial.println(MARK_EXCESS_MICROS);
            IrReceiver.compensateAndPrintIRResultAsCArray(&Serial, false); // Output the results as uint8_t source code array of ticks
            Serial.print(F("Result as microseconds array - compensated with MARK_EXCESS_MICROS="));
            Serial.println(MARK_EXCESS_MICROS);
            IrReceiver.compensateAndPrintIRResultAsCArray(&Serial, true); // Output the results as uint16_t source code array of micros
            IrReceiver.printIRResultAsCVariables(&Serial);  // Output address and data as source code variables

            IrReceiver.compensateAndPrintIRResultAsPronto(&Serial);

            /*
             * Example for using the compensateAndStorePronto() function.
             * Creating this String requires 2210 bytes program memory and 10 bytes RAM for the String class.
             * The String object itself requires additional 440 Bytes RAM from the heap.
             * This values are for an Arduino UNO.
             */
//        Serial.println();                                     // blank line between entries
//        String ProntoHEX = F("Pronto HEX contains: ");        // Assign string to ProtoHex string object
//        if (int size = IrReceiver.compensateAndStorePronto(&ProntoHEX)) {   // Dump the content of the IReceiver Pronto HEX to the String object
//            // Append compensateAndStorePronto() size information to the String object (requires 50 bytes heap)
//            ProntoHEX += F("\r\nProntoHEX is ");              // Add codes size information to the String object
//            ProntoHEX += size;
//            ProntoHEX += F(" characters long and contains "); // Add codes count information to the String object
//            ProntoHEX += size / 5;
//            ProntoHEX += F(" codes");
//            Serial.println(ProntoHEX.c_str());                // Print to the serial console the whole String object
//            Serial.println();                                 // blank line between entries
//        }
        }
        IrReceiver.resume();                            // Prepare for the next value
    }
}
posted @ 2022-01-26 17:55  二氢茉莉酮酸甲酯  阅读(248)  评论(0编辑  收藏  举报