Accessing IR Received data fields

I am using IR receiver coding based on changes to the IR libraries. The new code is

#include <Arduino.h>
#include <IRremote.h>
#define IR_PIN 11

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(8, OUTPUT);
  // digitalWrite(Led-pin, HIGH);
  Serial.begin(9600);   
  IrReceiver.begin(IR_PIN, ENABLE_LED_FEEDBACK);
  delay(3000);

}
void loop() {
 digitalWrite(8, LOW);
  if (IrReceiver.decode()) { 
    digitalWrite(8, HIGH); 
    IrReceiver.printIRResultShort(&Serial);
    Serial.println();
    Serial.println("next print?   ");
    IrReceiver.printIRResultAsCVariables(&Serial);
    Serial.println("----");
    IrReceiver.printIRResultShort(&Serial);
    Serial.println("--- +++ ---");
    // IrReceiver.printIRResultsShort(&value);
    delay(3000);
  //  if(Protocol == "NEC") {Serial.println(Protocol)};
  }
 digitalWrite(8, LOW);
  IrReceiver.resume();

}

I hope to access the individual fileds in the IR Receiver output. This lines in my code --- " IrReceiver.printIRResultShort(&Serial);" --- produce printing lines showing several fields --- names and data.

"Protocol=NEC Address=0xA3 Command=0x99 Raw-Data=0x66995CA3 32 bits LSB first
--- +++ ---
Protocol=NEC Address=0xA3 Command=0x99 Raw-Data=0x66995CA3 32 bits LSB first

next print?
uint16_t address = 0xA3;
uint16_t command = 0x99;
uint32_t data = 0x66995CA3;Protocol=NEC Address=0xA3 Command=0x99 Raw-Data=0x66995CA3 32 bits LSB first
--- +++ ---
Protocol=NEC Address=0xA3 Command=0x99 Raw-Data=0x66995CA3 32 bits LSB first

I want to access one of these fields ("Raw-Data)" to test for data value higher than 0x66000000 or in that range, How do I code instructions to access that particular field?

Tom Kane / Vancouver, B.C., Canada

I think this is what you want
uint32_t myData = IrReceiver.decodedIRData.decodedRawData;

All the print functions you are referencing in the IRRemote library are here
https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/IRReceive.hpp

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.