Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home Arduino & Microcontrollers

Arduino Infrared Remote Decoding: Control Anything with TV Remote

Arduino Infrared Remote Decoding: Control Anything with TV Remote

March 11, 2026 /Posted byJayesh Jain / 0

One of the most satisfying Arduino projects for beginners and intermediates alike is learning to arduino ir remote decode — capturing button presses from any TV remote control and using those signals to trigger actions in your circuit. IR remotes use the same invisible light that your TV uses, but with Arduino and a cheap TSOP1838 receiver, you can decode every button press and control LEDs, relays, servo motors, or even home appliances. This tutorial covers everything from wiring to decoding multiple remote protocols, and ends with three practical projects you can build today.

Table of Contents

  • How Infrared Remote Communication Works
  • Components You Need
  • Wiring the IR Receiver to Arduino
  • IRremote Library Setup and Decoding
  • Common IR Protocols: NEC, Sony, RC5
  • Project 1: LED Strip Controller
  • Project 2: Relay-Based Appliance Switch
  • Project 3: Servo Motor Controller
  • Troubleshooting IR Issues
  • Frequently Asked Questions

How Infrared Remote Communication Works

IR remotes work by flashing an infrared LED at a specific frequency — typically 38kHz (called the carrier frequency). This rapid flashing is modulated with data: the pattern of on/off pulses encodes button information. The TSOP1838 receiver (the small black three-pin module) has a built-in 38kHz bandpass filter and demodulator, so it ignores ambient IR (sunlight, lamps) and only responds to properly modulated 38kHz signals.

The output of the receiver is an inverted digital signal — LOW when receiving IR, HIGH when idle. This signal’s pulse pattern encodes the remote’s button data according to a specific protocol (NEC, Sony SIRC, Philips RC5, etc.). Each protocol has different pulse timings and bit-encoding rules.

NEC protocol (most common in Indian market):

  • Start burst: 9ms LOW + 4.5ms HIGH
  • Bit 0: 562µs LOW + 562µs HIGH
  • Bit 1: 562µs LOW + 1687µs HIGH
  • 32 bits total: 8-bit address + 8-bit inverted address + 8-bit command + 8-bit inverted command

The inverted address and command bytes act as error checking — if they don’t match their inversions, the packet is discarded. This makes NEC quite reliable despite operating in the noisy IR environment of a living room.

Components You Need

  • Arduino Uno, Nano, or any Arduino-compatible board
  • TSOP1838 (or VS1838B) IR receiver module — the 3-pin version with built-in demodulator
  • Any TV, set-top box, or DVD remote control
  • 100Ω resistor (optional, for LED current limiting in projects)
  • Breadboard and jumper wires
  • Additional components depending on your project (LED strip, relay, servo)

Note: Use the TSOP1838 module (which has a built-in demodulator and outputs clean digital signals), not a bare IR photodiode. The bare diode requires an analogue comparator circuit and is far harder to work with.

Recommended: Arduino Uno R3 Beginners Kit — Complete starter kit with Arduino Uno, breadboard, and jumper wires — everything you need except the IR receiver to follow this tutorial.

Wiring the IR Receiver to Arduino

The TSOP1838 has three pins. Looking at the flat face of the component from left to right: OUT, GND, VCC (note: pin order varies by manufacturer — always check the datasheet).

TSOP1838 Pin Arduino Pin
VCC 5V
GND GND
OUT (Signal) D11 (default)

Add a 100nF capacitor between VCC and GND as close to the TSOP as possible to filter power supply noise — this dramatically reduces false triggers. The IRremote library uses D11 as the default receive pin on Uno, but this can be changed in the library settings.

IRremote Library Setup and Decoding

Install the IRremote library by shirriff/ArminJo from Arduino Library Manager (version 4.x recommended). This is the most actively maintained IR library and supports 20+ protocols.

Here’s the basic receiver sketch to decode any remote:

#include <IRremote.hpp>

#define IR_RECEIVE_PIN 11

void setup() {
  Serial.begin(115200);
  IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
  Serial.println("Ready to receive IR signals...");
}

void loop() {
  if (IrReceiver.decode()) {
    Serial.print("Protocol: ");
    Serial.println(IrReceiver.decodedIRData.protocol);
    Serial.print("Address:  0x");
    Serial.println(IrReceiver.decodedIRData.address, HEX);
    Serial.print("Command:  0x");
    Serial.println(IrReceiver.decodedIRData.command, HEX);
    Serial.println();
    IrReceiver.resume(); // Enable receiving of next value
  }
}

Point your TV remote at the receiver and press each button while watching the Serial Monitor (115200 baud). Write down the hex command value for each button you want to use. These are the codes your project will respond to.

The ENABLE_LED_FEEDBACK flag causes the Arduino’s built-in LED (D13) to blink on each received signal — useful for debugging distance and angle issues.

Common IR Protocols: NEC, Sony, RC5

NEC: Used by most Indian market remote controls (LG, Samsung generic, local brands). 32-bit packets, one-shot and repeat codes. The IRremote library decodes NEC with high reliability. Command values are 8-bit (0x00–0xFF).

Sony SIRC: Used by all Sony products. Can be 12, 15, or 20-bit variants. Sony remotes typically repeat the same command 3 times per button press (required by the SIRC spec). Use IRDATA_FLAGS_IS_REPEAT flag to detect held keys vs. single presses.

Philips RC5: Bi-phase encoded protocol used by Philips, Marantz, and some European brands. 14-bit packets with a toggle bit that flips on each new button press. This is how you distinguish between a held key and a new press.

RC6: Extended RC5 used by Sky, Windows Media Center remotes. More complex but IRremote library handles it transparently.

For most projects, you don’t need to know the protocol — just record the command hex values and match them in your code. The IRremote library decodes the protocol automatically.

Recommended: Arduino Nano Every with Headers — Compact and powerful, the Nano Every is perfect for embedding IR control into small enclosures like remote-controlled appliance boxes.

Project 1: LED Strip Controller

Control an RGB LED strip or a set of single-colour LEDs using your TV remote’s number keys and colour buttons.

#include <IRremote.hpp>

#define IR_RECEIVE_PIN 11
#define LED_PIN        9   // PWM pin

// Replace with codes from YOUR remote (record them first)
#define BTN_POWER  0x45
#define BTN_VOL_UP 0x46
#define BTN_VOL_DN 0x15

int brightness = 128;
bool ledOn = true;

void setup() {
  IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
  pinMode(LED_PIN, OUTPUT);
  analogWrite(LED_PIN, brightness);
}

void loop() {
  if (IrReceiver.decode()) {
    uint8_t cmd = IrReceiver.decodedIRData.command;
    if (!(IrReceiver.decodedIRData.flags & IRDATA_FLAGS_IS_REPEAT)) {
      if (cmd == BTN_POWER) {
        ledOn = !ledOn;
        analogWrite(LED_PIN, ledOn ? brightness : 0);
      }
    }
    // Allow repeat for brightness control
    if (cmd == BTN_VOL_UP && brightness < 255) {
      brightness = min(255, brightness + 15);
      if (ledOn) analogWrite(LED_PIN, brightness);
    }
    if (cmd == BTN_VOL_DN && brightness > 0) {
      brightness = max(0, brightness - 15);
      if (ledOn) analogWrite(LED_PIN, brightness);
    }
    IrReceiver.resume();
  }
}

The IRDATA_FLAGS_IS_REPEAT check ensures the power toggle only fires on the first press, not on every auto-repeat. Volume buttons deliberately allow repeat for smooth brightness ramping while holding the key.

Project 2: Relay-Based Appliance Switch

This project turns mains-powered appliances on and off with remote button presses. Always use a fully enclosed relay module — never work with bare mains wiring.

#include <IRremote.hpp>

#define IR_RECEIVE_PIN 11
#define RELAY1 4
#define RELAY2 5
#define RELAY3 6
#define RELAY4 7

// Map number keys 1-4 to relays
const uint8_t BTN_1 = 0x0C; // Replace with your remote's codes
const uint8_t BTN_2 = 0x18;
const uint8_t BTN_3 = 0x5E;
const uint8_t BTN_4 = 0x08;

bool relayState[4] = {false, false, false, false};

void setup() {
  IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
  for (int i = 4; i <= 7; i++) {
    pinMode(i, OUTPUT);
    digitalWrite(i, HIGH); // Active-low relay: HIGH = OFF
  }
}

void toggleRelay(int index) {
  relayState[index] = !relayState[index];
  digitalWrite(4 + index, relayState[index] ? LOW : HIGH);
}

void loop() {
  if (IrReceiver.decode()) {
    if (!(IrReceiver.decodedIRData.flags & IRDATA_FLAGS_IS_REPEAT)) {
      uint8_t cmd = IrReceiver.decodedIRData.command;
      if (cmd == BTN_1) toggleRelay(0);
      if (cmd == BTN_2) toggleRelay(1);
      if (cmd == BTN_3) toggleRelay(2);
      if (cmd == BTN_4) toggleRelay(3);
    }
    IrReceiver.resume();
  }
}

This creates a 4-channel toggle switch controllable from your couch. Each button press toggles the corresponding relay between on and off. Add an I2C LCD to display the current state of each channel.

Recommended: 12V 4-Channel Relay Module with Optocoupler Isolation for Arduino — Optocoupler isolation protects your Arduino from relay switching transients. Essential for safe appliance control.

Project 3: Servo Motor Controller

Control a servo motor’s position with arrow keys from your remote — useful for remotely adjustable camera mounts, blinds, or robotic joints.

#include <IRremote.hpp>
#include <Servo.h>

#define IR_RECEIVE_PIN 11
#define BTN_LEFT  0x07  // Replace with your remote codes
#define BTN_RIGHT 0x09
#define BTN_OK    0x15

Servo myServo;
int servoPos = 90;  // Start at centre

void setup() {
  IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
  myServo.attach(9);
  myServo.write(servoPos);
}

void loop() {
  if (IrReceiver.decode()) {
    uint8_t cmd = IrReceiver.decodedIRData.command;
    if (cmd == BTN_LEFT)  servoPos = max(0,   servoPos - 5);
    if (cmd == BTN_RIGHT) servoPos = min(180, servoPos + 5);
    if (cmd == BTN_OK)    servoPos = 90;  // Centre
    myServo.write(servoPos);
    IrReceiver.resume();
  }
}

Hold the left/right key and the servo sweeps smoothly (thanks to auto-repeat from the remote). Press OK to snap back to centre. Add a second servo on a different pin for pan-tilt camera control.

Troubleshooting IR Issues

  • No signal decoded: Verify the TSOP’s OUT pin is connected to D11, and add the 100nF decoupling cap. Check that the receiver is getting 5V with a multimeter.
  • Wrong codes / UNKNOWN protocol: Some remotes use non-standard protocols. Try increasing the raw timeout: IrReceiver.setReceivePin(11) with a longer mark excess.
  • Conflict with PWM on D11: On Arduino Uno, D11 is also the MOSI SPI pin and Timer 2 PWM. If you’re using SPI or analogWrite(11), move the IR receiver to D12 and change IR_RECEIVE_PIN accordingly.
  • IR receiver triggered by sunlight or lamps: Direct sunlight through a window can overwhelm the TSOP. Shield the receiver or point it away from light sources. The 100nF cap helps but can’t overcome direct IR flood.
  • Relay chattering on IR reception: Relay switching generates voltage spikes that reset the Arduino or cause spurious IR decodes. Add a flyback diode across relay coil and a 100µF cap on Arduino VCC.
Recommended: Arduino Mega 2560 R3 Board — For complex home automation projects with IR control, multiple relays, and LCD display, the Mega’s extra I/O pins and memory make everything easier.

Frequently Asked Questions

Can I use any TV remote with Arduino IR decode?

Yes, almost any IR remote will work. The IRremote library supports NEC, Sony, RC5, RC6, Samsung, LG, Panasonic, and 15+ other protocols. Even if your remote uses an unknown protocol, the library can capture raw timings that you can match manually.

What distance does IR remote control work over?

Typically 5–10 metres in a normal room with a TSOP1838 receiver. Range depends on the remote’s LED power, receiver sensitivity, and ambient light. In bright sunlight outdoors, range drops to 1–2 metres. In a dark room, some remotes work over 15 metres.

Can I send IR signals from Arduino as well as receive?

Yes. The IRremote library includes a sender. Connect an IR LED (with 100Ω series resistor) to D3 (the send pin on Uno) and use IrSender.sendNEC(address, command, repeats). This lets Arduino impersonate a remote control to automate TVs and air conditioners.

Why does the same button give different codes sometimes?

Protocols like RC5 include a toggle bit that flips on each new button press. This is by design — it distinguishes a new press from a held button. The IRremote library separates this into the IRDATA_FLAGS_IS_REPEAT flag. Filter by this flag to handle single presses vs. held keys correctly.

Can multiple Arduino projects share the same remote?

Yes — IR is broadcast, so multiple receivers in the same room will all decode the same signal. Add a second receiver to another Arduino project and assign different button codes to control different systems from one remote. This is how universal remotes work.

Ready to build your IR remote project? Browse our Arduino boards and sensors at Zbotic — with fast shipping across India and expert support for your electronics projects.

Tags: Arduino, home automation, infrared, IR remote, irremote library, NEC protocol, tutorial
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
Arduino SPI Communication: How...
blog arduino spi communication how to interface multiple devices 594709
blog arduino debounce fix button bounce issues once and for all 594711
Arduino Debounce: Fix Button B...

Related posts

Svg%3E
Read more

Arduino Batch Programming: Flash Multiple Boards Quickly

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading
Svg%3E
Read more

Arduino Based Radar System with Ultrasonic Sensor

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading
Svg%3E
Read more

Arduino Automatic Plant Monitor: Sunlight, Moisture, Temperature

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading
Svg%3E
Read more

Arduino Lie Detector: GSR Sensor Polygraph Project

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading
Svg%3E
Read more

Arduino Metal Detector: Build a Treasure Finder

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading

Add comment Cancel reply

Your email address will not be published. Required fields are marked

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now