Arduino Remote Control Tutorial

In this tutorial, I am going to show you exactly how to make an Arduino remote control. You can use this project to combine functions from different remote controls and make your super-awesome dream remote control!

IR diode connected to Arduino

If you are not familiar with Arduino, check out What is Arduino and Where to start?

A remote control sends out an infrared (IR) code when you push a button. The gadget you point the remote control at will receive this IR code. To make your own Arduino remote control, you need to first copy the IR code from an existing remote control using an IR receiver.

To create our remote control we need to:

  • Get the button code from the original remote
  • Make a remote-control program
  • Upload our program to the Arduino

We will use these components for our Arduino project:

Connect the hardware

We start by connecting the components to the Arduino. The IR receiver is a photodiode packaged with a filter and amplifier to make it easy to detect remote control signals. Here is how to connect the components:

Arduino Remote Control Connection Diagram

Get the Arduino-IRremote library

In this tutorial, we will use the Arduino-IRremote library. It is open-source and can be found at https://github.com/shirriff/Arduino-IRremote

We’ll download and install the library as described on their website. It’s basically just to download a zip file, unzip it and rename it. Then put it in the arduino/library/ folder.

This library includes everything we need to receive and send IR signals.

Retrieve the button code and protocol

First, we need to get the button code and protocol from the original remote.

In this tutorial we will copy the “Standby”-button from a Sandstrøm radio remote control.

To receive the IR code, we will use the IRrecvDemo example. You’ll find it in the example folder of the Arduino-IRremote folder (…/arduino/libraries/IRremote/examples/IRrecvDemo/IRrecvDemo.ino)

This example prints the code it receives. But we also want to know which protocol it uses. So we’ll modify the program slightly. We’ll add these two lines to the program:

Serial.print(“Protocol: “);
Serial.println(results.decode_type, DEC);

Modified arduino code for receiving IR codes

We’ll verify and upload our program to Arduino.

Then we open the Serial Monitor tool from the Tools menu.

Arduino Menu Serial Monitor

We point our remote control to the IR receiver and push the “Standby”-button one time.

Arduino with IR receiver

When we push the button, a code appears on the serial monitor. If we hold the button we will see several codes. But we’ll push only once and note the code that we receive.

Serial Monitor with Received IR Code

To figure out which protocol our remote is using we need to check out the IRremote.h file (…/arduino/libraries/IRremote/IRremote.h):

// Values for decode_type
#define NEC 1
#define SONY 2
#define RC5 3
#define RC6 4
#define DISH 5
#define SHARP 6
#define PANASONIC 7
#define JVC 8
#define SANYO 9
#define MITSUBISHI 10
#define UNKNOWN -1

We received a “1” as protocol. That means our remote control is using the NEC protocol.

Create a program using the protocol and button-code

Ok, we got the button code.

Now we will make a program so that we can send the code through the IR diode. Luckily, there is already an example in the Arduino-IRremote library that shows us how to do that.

Find the IRsendDemo file and open it (…/arduino/libraries/IRremote/examples/IRsendDemo/IRsendDemo.ino)

The program waits until it receives a character on the serial port. Then sends the IR code.

We scroll down to where the IR code is sent:

Arduino IR Send Code

Now we need to do some modifications.

In the example file, they are using the Sony protocol. But our Arduino remote control uses the NEC protocol (as we found above). So we need to find the right function to use for the NEC protocol.

To find the correct function to use for our protocol, we open up the IRremote.h file (…/arduino/libraries/IRremote/IRremote.h) and search for “class IRsend”. Here, we’ll see a bunch of different send methods in the class definition.

Class IRsend from IRremote.h

In our case, we need the function for the NEC protocol, so we choose the sendNEC() function.

Back in the program code we change from sendSony to sendNEC. Using the NEC protocol we need to send 32 bits. So we change the number of bits to 32.

Then we take the button code that we found, FF01FE, and copy it into the program:

arduino-ir-send-demo-modified

Now, let’s verify and upload the sketch to our Arduino.

Test the Arduino Remote Control

It is time to test our Arduino remote control.

We open the Serial Monitor again. Then point the IR diode to the radio. We type in a character in the Serial Monitor and push the “Send” button.

Arduino Serial Monitor

And our radio magically turns on =) We have made an Arduino remote control!

More Arduino Tutorials