Random Nerd Tutorials

Arduino – Control LEDs with IR Remote Control


In this project you’ll use an infrared (IR) receiver and an Arduino to control 3 LEDs with a remote control. This is useful to re-use old remote controls or give some functionally to some of your remote’s buttons.

This project is divided into two parts:

  1. You’ll decode the IR signals transmitted by your remote control
  2. You’ll use that info to perform a task with your Arduino (control 3 LEDs)

Parts required

To follow this project you need the following parts:

You can use the preceding links or go directly to MakerAdvisor.com/tools to find all the parts for your projects at the best price!

Introducing the Infrared (IR) Receiver

The infrared receiver is the component shown in the figure below. This is the TSOP4838.

IR receiver labels

Infrared receiver pins:

  • First pin: Vout
  • Second pin: GND
  • Third pin: Vcc

When you press your remote control, it sends infrared modulated signals. These signals contain information that your receiver collects.

Each button sends specific information. So, we can assign that information to a specific button.

Decode the IR signals

In this part of the project you need to decode the IR signals associated with each button.



Connect the IR receiver accordingly to the schematics below.


To control the IR receiver, you need to install the IRremote Library  in the Arduino IDE.

Installing the IRremote library

  1. Click here to download the IRremote library. You should have a .zip folder in your Downloads
  2. Unzip the .zip folder and you should get IRremote-master folder
  3. Rename your folder from IRremote-master to IRremote
  4. Move the IRremote folder to your Arduino IDE installation libraries folder
  5. Finally, re-open your Arduino IDE

Copy the following code to your Arduino IDE, and upload it to your Arduino board. Make sure that you have the right board and COM port selected.

Open the serial monitor at a baud rate of 9600.

In this project you want to control 3 LEDs. Choose 6 buttons for the following tasks:

  1. LED1 – ON
  2. LED1 – OFF
  3. LED2 – ON
  4. LED2 – OFF
  5. LED3 – ON
  6. LED3 – OFF

Press, for example, the button number 1 of your remote control. You should see a code on the serial monitor. Press the same button several times to make sure you have the right code for that button. If you see something like FFFFFFFF ignore it, it’s trash.

Do the same for the other buttons.

Write down the code associated with each button, because you’ll need that information later.

Building the final circuit

In this part, you’ll build the circuit with three LEDs that will be controlled using your remote.


Assemble all the parts by following the schematics below.


Now, grab the codes you captured in the previous step. You need to convert your codes from hex to decimal.

For that, you can use the following website: www.binaryhexconverter.com/hex-to-decimal-converter

Here’s a conversion example for one of my codes:

Repeat that process to all your hex values and save the decimal values. These are the ones you need to replace in the code below.

Download or copy the following sketch to your Arduino IDE. Write your own decimal values in the sketch provided in the case lines and upload it to your Arduino board. Make sure that you have the right board and COM port selected.


In the end you can control each LED individually using the buttons of your remote control.

Watch the video demonstration

Wrapping Up

This is a great project to learn about the IR receiver. There are endless possibilities for what you can do with it.

For example, you can replace those LEDs with a relay to control your house appliances.

This can be particularly useful because some remotes have a bunch of buttons that you never use. So, why not use them to do something useful?

This is an excerpt from our course: Arduino Step-by-step projects. If you like Arduino and you want to build more projects, we recommend enrolling in the Arduino Step-by-step projects course.

Learn ESP32 with Arduino IDE

This is our complete guide to program the ESP32 with Arduino IDE, including projects, tips, and tricks! The registrations are open, so SIGN UP NOW »

Recommended Resources

Home Automation using ESP8266 »
Build IoT projects and home automation gadgets with the ESP8266 Wi-Fi module.

Build a Home Automation System »
Learn how to build a automation system using open-source hardware and software from scratch.

Arduino Step-by-Step Projects »
Build 25 cool Arduino projects with our course even with no prior experience!

Leave a Comment:

Add Your Reply

Enroll in our Electronics and Programming Courses:

ESP32, ESP8266, Arduino and much more.