Using the Infrared IR Remote Transceiver with Arduino involves wiring up the transceiver to your Arduino-compatible microcontroller, installing the IRremote library and running the provided example code.
You'll need an IR remote controller to use this example:

This receiver on this board is specifically for receiving 38KHz IR remote control signals - it isn't going to work for proximity/distance sensing or other frequency signals.
Wiring
Wire as shown for a 5V board like an Uno. If you are using a 3V board, like an Adafruit Feather, wire the board's 3V pin to the transceiver VIN.
Here is an Adafruit Metro wired up to the transceiver using the STEMMA JST PH cable:
- Board 5V to VIN (red wire)
- Board GND to GND (black wire)
- Board pin 5 to IRin (white wire)
- Board pin 6 to IRout (green wire)
Here is an Adafruit Metro wired up using a solderless breadboard:
- Board 5V to VIN (red wire)
- Board GND to GND (black wire)
- Board pin 5 to IRin (white wire)
- Board pin 6 to IRout (green wire)
Library Installation
You can install the IRremote library for Arduino using the Library Manager in the Arduino IDE.
Click the Manage Libraries ... menu item, search for IRremote, and select the IRremote library:
There are no additional dependencies needed for this library.
// SPDX-FileCopyrightText: 2024 Liz Clark for Adafruit Industries // // SPDX-License-Identifier: MIT /* * Based on the SimpleReceiver.cpp and SimpleSender.cpp from the * Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote. * by Armin Joachimsmeyer ************************************************************************************ * MIT License * * Copyright (c) 2020-2023 Armin Joachimsmeyer * */ #include <Arduino.h> #include <IRremote.hpp> // include the library #define IR_RECEIVE_PIN 5 #define IR_SEND_PIN 6 void setup() { Serial.begin(115200); while (!Serial) ; Serial.println("Adafruit STEMMA IR Transceiver Demo"); IrReceiver.begin(IR_RECEIVE_PIN); IrSender.begin(IR_SEND_PIN); // Start with IR_SEND_PIN -which is defined in PinDefinitionsAndMore.h- as send pin and enable feedback LED at default feedback LED pin Serial.print("IRin on pin "); Serial.print(IR_RECEIVE_PIN); Serial.print(", IRout on pin "); Serial.println(IR_SEND_PIN); } uint8_t sCommand = 0x34; uint8_t sRepeats = 0; void loop() { /* * Check if received data is available and if yes, try to decode it. * Decoded result is in the IrReceiver.decodedIRData structure. * * E.g. command is in IrReceiver.decodedIRData.command * address is in command is in IrReceiver.decodedIRData.address * and up to 32 bit raw data in IrReceiver.decodedIRData.decodedRawData */ if (IrReceiver.decode()) { if (IrReceiver.decodedIRData.protocol == UNKNOWN) { IrReceiver.printIRResultRawFormatted(&Serial, true); IrReceiver.resume(); } else { IrReceiver.resume(); IrReceiver.printIRResultShort(&Serial); IrReceiver.printIRSendUsage(&Serial); delay(1000); Serial.println("Sending received command.."); IrSender.sendNEC(IrReceiver.lastDecodedProtocol, IrReceiver.lastDecodedCommand, IrReceiver.repeatCount); delay(1000); Serial.print("Sent!"); //Serial.println(IrReceiver.lastDecodedProtocol, IrReceiver.lastDecodedCommand, IrReceiver.repeatCount); } Serial.println(); } }
Upload the sketch to your board and open up the Serial Monitor (Tools -> Serial Monitor) at 115200 baud. As you press buttons on your IR remote, you'll see the protocol, address, command, raw data and repeat gap print to the Serial Monitor. Then, the breakout will send the received IR code via the IR LEDs.
Page last edited January 22, 2025
Text editor powered by tinymce.