Skip to main content

DIY Arduino IR Remote & IR Receiver Tutorial | Decode and Send IR Signals

Infrared (IR) communication is one of the most widely used wireless technologies in everyday electronics. Television remotes, air conditioners, music systems, and many household appliances rely on IR signals to communicate. 

In this tutorial, you will learn how to:
  • Decode signals from an existing remote
  • Build your own DIY Arduino IR remote
  • Control LEDs wirelessly using IR communication
  • Understand how IR protocols work
By the end of this project, you will have a complete understanding of how IR remotes work and how to build your own custom wireless controller.

How IR Communication Works

IR communication uses infrared light, which is invisible to the human eye. When you press a button on a remote, it sends a pattern of IR pulses that represent a digital code.
The process:
  1. Remote sends modulated IR signal (usually 38kHz).
  2. IR receiver detects and demodulates the signal.
  3. Arduino decodes the signal into a HEX value.
  4. Arduino performs an action based on the received code.
Each button on a remote sends a unique HEX code.

Project Overview

This project uses two Arduino boards:
  • Arduino Nano → acts as the DIY IR remote (transmitter)
  • Arduino Uno → acts as the IR receiver and LED controller

System Flow

Button press → IR LED transmits → IR Receiver reads → Arduino compares code → LED turns ON/OFF

Watch Project Overview

Components Required


To simplify the process, you may first try this project using two push buttons and LEDs before implementing the full four-button version shown in the project.
  • Arduino Uno - IR Receiver + LED Controller
  • Arduino Nano - DIY IR remote
  • IR Receiver (KY-022) - Receives IR signals
  • IR Transmitter (KY-005 or IR LED) - Sends IR signals
  • Push Buttons (x2) - Remote buttons
  • LEDs (x2) - Output Devices
  • 220Ω Resistors (x2) - LED current limiting
  • Breadboard and Jumper wires - Connections 

Understanding the Modules

IR Receiver (KY-022)

This module detects 38kHz IR signals and converts them into digital data readable by Arduino.

IR Transmitter (KY-005)

This module sends modulated IR signals, similar to a TV remote.

Wiring - IR Receiver Circuit (Arduino Uno)

IR Receiver Pin

                    Arduino Uno Pin

VCC                        5V
GND                        GND
OUT                        D11

LEDs

LED

                                    Arduino Pin

LED 1                                    D7
LED 2                                    D6

Wiring - DIY IR Remote (Arduino Nano)

Component

                        Nano Pin

IR LED Signal                        D3
Button 1                        D4
Button 2                        D5

Buttons will use INPUT_PULLUP, so no external resistors are required.

Install Required Library

Open Arduino IDE:
Sketch → Include Library → Manage Libraries
Search and install:
IRremote by shirriff / ArminJo
This library allows sending and receiving IR signals easily

Step 01: Decode an Existing Remote

Before building our remote, we must learn how IR codes work.
Upload this sketch to the Arduino Uno.
#include <IRremote.h>

const int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup() {
  Serial.begin(9600);
  irrecv.enableIRIn();
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume();
  }
}

Open Serial Monitor and press buttons on any TV remote.
You will see HEX codes like:
FFA25D
FF629D
FFE21D

Each button has a unique code.
Write down two codes to use in your project.

Step 02: Program the DIY IR Remote (Arduino Nano)

Upload this code to the Arduino Nano.
#include <IRremote.h>

IRsend irsend;

const int button1 = 4;
const int button2 = 5;

void setup() {
  pinMode(button1, INPUT_PULLUP);
  pinMode(button2, INPUT_PULLUP);
}

void loop() {

  if(digitalRead(button1) == LOW) {
    irsend.sendNEC(0xFFA25D, 32); // Button 1 code
    delay(300);
  }

  if(digitalRead(button2) == LOW) {
    irsend.sendNEC(0xFF629D, 32); // Button 2 code
    delay(300);
  }
}
Replace HEX codes with the ones you captured earlier.

Step 03: Program the IR Receiver and LED Controller (Uno)

Upload this final sketch to Arduino Uno.
#include <IRremote.h>

const int RECV_PIN = 11;
const int led1 = 7;
const int led2 = 6;

IRrecv irrecv(RECV_PIN);
decode_results results;

void setup() {
  Serial.begin(9600);
  irrecv.enableIRIn();
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
}

void loop() {
  if (irrecv.decode(&results)) {

    if(results.value == 0xFFA25D) {
      digitalWrite(led1, !digitalRead(led1));
    }

    if(results.value == 0xFF629D) {
      digitalWrite(led2, !digitalRead(led2));
    }

    irrecv.resume();
  }
}

Testing the Project

  1. Power both Arduino boards.
  2. Press button 1 → LED 1 toggles.
  3. Press button 2 → LED 2 toggles.
You have successfully built your own IR remote system.

Troubleshooting Guide

Problem: No signal received

  • Check wiring of IR receiver OUT pin
  • Ensure correct pin number in code

Problem: Short range

  • Use transistor to drive IR LED
  • Ensure IR LED faces receiver

Problem: Random codes appearing

  • Avoid bright sunlight or fluorescent lights

Problem: Buttons trigger multiple times

  • Increase delay in transmitter code

Conclusion

In this tutorial, you learned how infrared communication works and how to build a complete IR transmitter and receiver system using Arduino.
You now know how to decode remote signals, transmit your own IR codes, and wirelessly control devices. This knowledge is the foundation for building custom home automation and wireless control systems.

Frequently Asked Questions (FAQ)

What is the typical range of an IR remote?

Most IR remotes work reliably within 5-10 meters in indoor environments.

Can I control my TV using this project?

Yes. First decode your TV remote buttons, then transmit the same codes from your Arduino remote.

Why are we using two Arduino boards?

One acts as the transmitter (remote) and the other acts as the receiver/controller. This helps you understand both sides of IR communication.

Can I use a single Arduino instead?

Yes. After learning, you can combine receiver and transmitter on one board.

Why do we use INPUT_PULLUP for buttons?

This avoids external resistors and keeps wiring simple for beginners.

Does sunlight affect IR communication?

Yes. Strong sunlight and fluorescent lighting can interfere with IR signals.

Comments

Popular posts from this blog

Arduino Serial Communication Beginner Guide (UART Explained)

Serial communication is the backbone of most Arduino projects. It allows your Arduino to talk to your computer, Bluetooth modules, Wi-Fi modules, sensors, and even other Arduinos. If you have ever used the Serial Monitor, you have already used serial communication - now you will understand how it really works. By the end of this guide, you will learn: What serial communication is What UART means How Arduino communicates with devices How to send and receive data How baud rate works Common mistakes beginners make What is Serial Communication? Serial communication is a method of sending data one bit at a time over a single wire. Instead of sending many bits simultaneously (parallel communication), serial sends bits sequentially: Example: The letter A in binary = 01000001 These bits are sent one after another very quickly. This method is: Simple Reliable Perfect for microcontrollers What is UART? UART stands for: Universal Asynchronous Receiver Transmitter It is the hardware ins...

How to Connect HC-06 Bluetooth Module with Arduino (Step-by-Step Beginner Guide)

Bluetooth communication is one of the easiest ways to make Arduino projects wireless. Once you understand how to use a Bluetooth module, you can build robots, home automation systems, and smartphone-controlled devices. In this tutorial, you will learn how to interface the HC-06 Bluetooth module with Arduino and send data wirelessly using your phone.    By the end of this guide, you will be able to: Understand how the HC-06 Bluetooth module works Configure the module using AT commands Safely connect it to an Arduino Send and receive serial data over Bluetooth Build the foundation for wireless Arduino projects Watch the Project Overview What is the HC-06 Bluetooth Module? The HC-06 is a Bluetooth-to-Serial module designed to add wireless communication to microcontrollers such as Arduino. It uses Bluetooth 2.0 (SPP - Serial Port Protocol), which means it behaves like a wireless serial cable. Whatever is sent from the phone appears in Arduino’s Serial Monitor and vice versa. ...

How to Use SoftwareSerial on Arduino (Connect Multiple Serial Devices)

In the previous tutorial, you learned how Arduino uses hardware serial communication through pins 0 (RX) and 1 (TX). That built-in serial port is mainly used to communicate with your computer through the USB cable and Serial Monitor . But here is the problem beginners quickly face: Many popular modules use serial communication, such as: Bluetooth modules ( HC-05 / HC-06 ) GPS modules GSM modules Wi-Fi modules ( ESP8266 ) Arduino Uno has only one hardware serial port. So how can we connect these modules while still using the Serial Monitor? The solution is SoftwareSerial . In this tutorial you will learn how to create additional serial ports using normal digital pins. By the end, your Arduino will be able to talk to multiple serial devices. What is SoftwareSerial? SoftwareSerial is a special Arduino library that allows digital pins to behave like RX and TX pins. This means Arduino can create extra serial ports using software instead of hardware. Hardware Serial vs Software Seri...