IR Emitter

Updated on 31 August 2021
dev board Arduino UNO
chip ATmega328p
sensor infrared
features infrared IR emitter
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-emitter.ino
#include <IRLibAll.h>

IRrecvPCI myReceiver(2);  // Arduino UNO PIN 2
IRdecode myDecoder;

IRsend mySender;

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

  myReceiver.enableIRIn();
  Serial.println("Ready to receive IR signals...");

  Serial.println("Ready to receive character into the serial monitor...");
}

void loop() {
  if (myReceiver.getResults()) {
    myDecoder.decode();
    myDecoder.dumpResults(true);
    myReceiver.enableIRIn();
  }

  // Send a character into the serial monitor
  if (Serial.read() != -1) {
    // Decoded NEC(1): Value:CE01F Adrs:0 (32 bits)
    mySender.send(NEC, 0xce01f, 32);  // Get the HEX code with IR receiver
    Serial.println("Sent Eco Blank to the projector");
  }
}

Makefile

.PHONY: lint compile upload clean

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

compile:
	arduino-cli compile --fqbn arduino:avr:uno ./

upload:
	arduino-cli upload -p /dev/cu.usbmodem14* --fqbn arduino:avr:uno ./

clean:
	rm -f .*.hex
	rm -f .*.elf

flash: lint compile upload clean

Prototype

A photo of the actual setup.

IR Emitter prototype

Schematic

Wire up the hardware accordingly

IR Emitter schematic

Serial console

Serial output from the firmware.

IR Emitter serial console

Description

Get the HEX code to emit using the IR receiver program. This code contains both IR receiver and IR emitter logic.

References