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:
The process:
Buttons will use INPUT_PULLUP, so no external resistors are required.
Sketch → Include Library → Manage Libraries
Search and install:
IRremote by shirriff / ArminJo
This library allows sending and receiving IR signals easily
Upload this sketch to the Arduino Uno.
Open Serial Monitor and press buttons on any TV remote.
You will see HEX codes like:
Each button has a unique code.
Write down two codes to use in your project.
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.
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
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:
- Remote sends modulated IR signal (usually 38kHz).
- IR receiver detects and demodulates the signal.
- Arduino decodes the signal into a HEX value.
- Arduino performs an action based on the received 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/OFFWatch 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
IR Receiver Pin | Arduino Uno Pin |
|---|---|
| VCC | 5V |
| GND | GND |
| OUT | D11 |
LEDs
LED
Arduino Pin
LED 1 D7 LED 2 D6
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.Component | Nano Pin |
|---|---|
| IR LED Signal | D3 |
| Button 1 | D4 |
| Button 2 | D5 |
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
- Power both Arduino boards.
- Press button 1 → LED 1 toggles.
- Press button 2 → LED 2 toggles.
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.






Comments
Post a Comment