IR Receiver raw codes

Updated on 31 August 2021
dev board RobotDyn M0 mini
sensor infrared
features infrared IR receive raw
This tutorial is more than 1 year old. If the steps below do not work, then please check the latest versions and the documentations of the individual tools used.

Before starting

Dependancies

Ensure the following dependancies are downloaded and available:

Pre-requisites

Try these simpler or similar examples:

Buy the components

Code

Download code ir-raw-receive-zero.ino
#include <IRLibRecvPCI.h>

IRrecvPCI myReceiver(5);  // Arduino ZERO pin 5

void setup() {
  SerialUSB.begin(9600);

  myReceiver.enableIRIn();
  SerialUSB.println("Ready to receive IR signals");
  SerialUSB.println("Point the remote controller to the IR receiver and press!");
}

void loop() {
  if (myReceiver.getResults()) {
    // SerialUSB.println("\n\n-------------------------");
    SerialUSB.println("\nReceived IR signal:");

    SerialUSB.print(F("#define RAW_DATA_LEN "));
    SerialUSB.println(recvGlobal.recvLength, DEC);

    // SerialUSB.print(F("uint16_t rawData[RAW_DATA_LEN]={\n"));
    // for (bufIndex_t i = 1; i < recvGlobal.recvLength; i++) {
    //   SerialUSB.print(recvGlobal.recvBuffer[i], DEC);
    //   SerialUSB.print(F(", "));
    //   if ((i % 8) == 0) {
    //     SerialUSB.print(F("\n"));
    //   }
    // }
    // SerialUSB.println(F("1000};"));
    // SerialUSB.println("-------------------------");

    myReceiver.enableIRIn();
  }
}

Makefile

BOARD?=arduino:samd:mzero_bl
PORT?=/dev/cu.usbmodem14*

.PHONY: default lint all flash clean

default: lint all flash clean

lint:
	cpplint --extensions=ino --filter=-legal/copyright,-whitespace/line_length *.ino

all:
	arduino-cli compile --fqbn $(BOARD) ./

flash:
	arduino-cli upload -p $(PORT) --fqbn $(BOARD)

clean:
	rm -r build

Description

This code dumps the raw IR code length when detected.

References