Arduino IR Receiver and Transmitter Tutorial
Infrared (IR) remote control systems are commonly used in everyday devices, like televisions, air conditioners, and home entertainment systems. With Arduino and the IRremote library, you can build your own IR Remote Arduino (receiver and transmitter) for various purposes. This guide will walk you through creating both an IR Receiver and an IR Transmitter using Arduino, leveraging protocols like NEC, Sony, RC5, and RC6.
Whether you’re trying to build a Samsung IR Remote, control a Vizio IR Remote, or implement an iPhone IR TV Remote, this guide will show you how to manage infrared remote control repeaters, universal IR remote controls, and more.
Arduino IR Remote Receiver
1. Explanation
An IR receiver allows you to receive and decode signals from your IR remote. Using this setup, you can create projects like controlling an LED, reading signals from a Samsung infrared remote, or understanding codes from your TCL infrared remote.
2. Circuit Diagram
You will need:
- Arduino board (e.g Arduino Uno)
- IR receiver module (e.g., TSOP1738, VS1838B)
- Resistors
- RGB LED (optional)

Make sure the IR receiver’s output pin connects to pin 2 on your Arduino. Or, to make it easier to use, we can also use the ready-to-use IR Remote module in the following image:
3. Library
Install the IRremote library through the Arduino IDE Library Manager. This will allow you to decode IR signals from devices like the Hisense Roku TV IR remote or Directv RC73 IR RF remote control, or download the library using this button:
If you don’t know how to add libraries to the Arduino IDE, you can read the article “How to Add Libraries to the Arduino IDE“.
4. Code to Scan Button Codes
The following code allows you to receive IR signals and print the button codes in hexadecimal format to the serial monitor.
#include <IRremote.h>
#define PIN_RECEIVER 2
IRrecv receiver(PIN_RECEIVER);
decode_results results;
void setup() {
Serial.begin(9600);
receiver.enableIRIn();
}
void loop() {
if (receiver.decode()) {
Serial.print("Button Code: 0x");
Serial.println(receiver.decodedIRData.command, HEX);
receiver.resume();
}
}
5. Code to Control RGB LED
This example shows how to control an RGB LED with specific IR remote codes. We’ll turn on different colors based on the button pressed.
Circuit:
- Connect the red, green, and blue legs of the RGB LED to three digital pins (e.g., 9, 10, and 11) on the Arduino through resistors (330Ω).
- cathode leg goes to GND.

Code:
#include <IRremote.h>
#define PIN_RECEIVER 2
#define LED_RED 9
#define LED_GREEN 10
#define LED_BLUE 11
IRrecv receiver(PIN_RECEIVER);
decode_results results;
void setup() {
receiver.enableIRIn();
pinMode(LED_RED, OUTPUT);
pinMode(LED_GREEN, OUTPUT);
pinMode(LED_BLUE, OUTPUT);
}
void loop() {
if (receiver.decode()) {
switch (receiver.decodedIRData.command) {
case 0x30: // Red
digitalWrite(LED_RED, HIGH); //Turn ON RED
digitalWrite(LED_GREEN, LOW);
digitalWrite(LED_BLUE, LOW);
break;
case 0x18: // Green
digitalWrite(LED_RED, LOW);
digitalWrite(LED_GREEN, HIGH); //Turn ON GREEN
digitalWrite(LED_BLUE, LOW);
break;
case 0x7A: // Blue
digitalWrite(LED_RED, LOW);
digitalWrite(LED_GREEN, LOW);
digitalWrite(LED_BLUE, HIGH); //Turn ON BLUE
break;
default:
digitalWrite(LED_RED, LOW);
digitalWrite(LED_GREEN, LOW);
digitalWrite(LED_BLUE, LOW);
break;
}
receiver.resume();
}
}
6. Code to Identify Protocol
You can also detect which protocol the IR remote is using (e.g., NEC, Sony, RC5) by checking the protocol type. Here’s the code:
#include <IRremote.h>
#define PIN_RECEIVER 2
IRrecv receiver(PIN_RECEIVER);
decode_results results;
void setup() {
Serial.begin(9600);
receiver.enableIRIn();
}
void loop() {
if (receiver.decode()) {
Serial.print("Protocol: ");
switch (receiver.decodedIRData.protocol) {
case NEC: Serial.println("NEC"); break;
case SONY: Serial.println("SONY"); break;
case RC5: Serial.println("RC5"); break;
case RC6: Serial.println("RC6"); break;
default: Serial.println("UNKNOWN");
}
receiver.resume();
}
}
Arduino IR Remote Transmitter
1. Explanation
The IR transmitter sends commands to control IR devices like TVs, AC units, or smart devices, such as Broadlink RM4 Pro. We’ll focus on NEC protocol here, but the steps apply to others like Sony or RC6.
2. Circuit Diagram
You will need:
- Arduino board
- IR LED
- 3 buttons
- Resistor for current limiting
An IR LED should be connected to pin 3 of the Arduino through a resistor (330Ω or 220Ω).
3. Library
Just like the receiver, you’ll need the IRremote library above.
4. Code to Send 3 Codes (NEC Protocol)
We will use 3 buttons to send IR codes. Configure the buttons using pull-up resistors.
#include <IRremote.h>
#define BUTTON_1 7
#define BUTTON_2 8
#define BUTTON_3 9
IRsend transmitter;
void setup() {
pinMode(BUTTON_1, INPUT_PULLUP);
pinMode(BUTTON_2, INPUT_PULLUP);
pinMode(BUTTON_3, INPUT_PULLUP);
}
void loop() {
if (digitalRead(BUTTON_1) == LOW) {
transmitter.sendNEC(0xA90, 32); // Send NEC code
delay(500);
}
if (digitalRead(BUTTON_2) == LOW) {
transmitter.sendNEC(0xB90, 32);
delay(500);
}
if (digitalRead(BUTTON_3) == LOW) {
transmitter.sendNEC(0xC90, 32);
delay(500);
}
}
5. Additional Protocols
To send codes using other protocols, simply replace sendNEC
with:
sendSony(code, bits)
for SonysendRC5(code, bits)
for RC5sendRC6(code, bits)
for RC6
6. Key Points and Additional Information
- Protokol Sony typically uses 12 to 20 bits.
- RC5 and RC6 protocols commonly use 12 and 20 bits.
- When connecting an IR LED, always use a current-limiting resistor to avoid damaging your components.
- For wireless IR repeaters, you can explore options like the Sewell IR Blaster or Bafx IR Repeater.
These concepts can be applied to work with a range of devices, from Samsung IR remotes, Roku IR remotes, to iPhone IR remote controls. Additionally, advanced systems like Broadlink RM4 Mini, harmony hub IR blaster, and SwitchBot IR Blaster expand these capabilities to smart home setups.
Similar search:
- tsop1738 ir receiver circuit
- ir receiver circuit
- tsop1738 circuit
- tsop1738 pdf datasheet
- ir receiver arduino
- ir receiver remote