In this course we will see how an infrared remote control is working and how to use one in your project.

The remote controls are all standard : if we take the example of a television, the remote control send an infrared signal and a receiver in your television will receipt and analyze this signal to change the channel for example.

This signal is digital, that’s mean it will by 0 and 1 which is be translated in hexadecimal by the receiver. Each hexadecimal signal corresponds to a button in the remote control.


Here is the hexadecimal code for each buttons of a remote control:

Hexadecimal Remote Control button
0xFF629D VOL+
0xFFA857 VOL-
0xFF906F UP
0xFF9867 EQ
Hexadecimal Bouton Télécommande
0xFF6897 0
0xFF30CF 1
0xFF18E7 2
0xFF7A85 3
0xFF10EF 4
0xFF38C7 5
0xFF5AA5 6
0xFF42BD 7
0xFF4AB5 8
0xFF52AD 9

In order to receive the message send by the remote control, we need a receiver. They are many infrared receiver, such as theses ones:

For the next sketchs, we will use the receiver ky-022.

How to install the IRemote library?

Before programming your Remote control, tou have to install the IRemote library in order to facilitate the using of the remote control.

To do that you have to go to “tools” from Arduino Ide and “Manages library”.

In the Manages library, you can type IRemote and download this library.

You are now ready to follow the course.

How to program your remote control

This program below allow you to display the button you have type on your remote control on the serial monitor.
#include "IRremote.h" // the library to use the remote control
int receiver = 11; // pin of the remote control
IRrecv irrecv(receiver);
decode_results results;
void translateIR() 
// describing Remote IR codes
case 0xFFA25D: Serial.println("POWER"); break;
case 0xFFE21D: Serial.println("FUNC/STOP"); break;
case 0xFF629D: Serial.println("VOL+"); break;
case 0xFF22DD: Serial.println("FAST BACK"); break;
case 0xFF02FD: Serial.println("PAUSE"); break;
case 0xFFC23D: Serial.println("FAST FORWARD"); break;
case 0xFFE01F: Serial.println("DOWN"); break;
case 0xFFA857: Serial.println("VOL-"); break;
case 0xFF906F: Serial.println("UP"); break;
case 0xFF9867: Serial.println("EQ"); break;
case 0xFFB04F: Serial.println("ST/REPT"); break;
case 0xFF6897: Serial.println("0"); break;
case 0xFF30CF: Serial.println("1"); break;
case 0xFF18E7: Serial.println("2"); break;
case 0xFF7A85: Serial.println("3"); break;
case 0xFF10EF: Serial.println("4"); break;
case 0xFF38C7: Serial.println("5"); break;
case 0xFF5AA5: Serial.println("6"); break;
case 0xFF42BD: Serial.println("7"); break;
case 0xFF4AB5: Serial.println("8"); break;
case 0xFF52AD: Serial.println("9"); break;
case 0xFFFFFFFF: Serial.println(" REPEAT");break;
Serial.println(" Other buttons ");
delay(500); // Time to wait the next signal
void setup() // Setup function which execute only once 
Serial.println("IR Receiver Button Decode");
irrecv.enableIRIn(); // We start the receiver
void loop() // Infinite loop 
if (irrecv.decode(&results)) // To know if the signal has been received 
irrecv.resume(); // To have the next value

Once the program uploaded, you can see the value of your button on the serial monitor by setting it at 9600 bauds (which is the default value). Before that you have to plug the Arduino board to your computer.

Here is the result:

As we can see, there are many “repeat” button on the serial monitor. Repeat means that the Receiver hasn’t understood what the signal from the remote control. It can be explained because to much noise has been added to the signal, therefore the signal can’t be decrypted.

Therefore we need a pull-up resistor to force the signal to 0 or 1.

Remote control with a pull-up resistor

Here is the new sketch with a pull-up resistor. We add a 220 ohms resistor because we have plug our receiver to the 3.3V pin.
For the program, nothing has changed. Here is what we can see on the serial monitor:
As we can see there is not repeat displayed, therefore the signal has been better received.

Remote control and a motor

We will see now how to to control a motor from a remote control to power on/off it. In this example we use a motor but it can be a different component.
Here is the program to upload on your Arduino card:
#include "IRremote.h" // The library to use the IR Remote
int receiver = 11; // Pin of the remote control
int motor=6;  // Pin of the motor
int State = 0; //  To define the state of the motor: 0 : Motor off and 1 : Motor On 

IRrecv irrecv(receiver);
decode_results results;

void setup(){
    Serial.begin(9600); //We start the serial monitor 
    Serial.println("Start decoding");
    irrecv.enableIRIn(); // We start decoding
void loop(){
    if (irrecv.decode(&results)) // To obtain the signal of the receiver 
        if (results.value == 0xFFA25D){
            Power_On_Off_motor(); //Function to power On and Off the motor 
        irrecv.resume(); // To receive the next value 
void Power_On_Off_motor(){
    if (State==0){ // If the value is 0 we turn ON the motor 
        digitalWrite(motor, HIGH);
    if (State==2){ // If the value is 2 we turn OFF the motor  
        digitalWrite(motor, LOW);
By uploading this program you can press the power button of your remote control to power on/off the motor.

Control your project from a phone!

In our Arduino Factory Application, we have developed a Bluetooth remote to control your project remotely. Our remote control has two designs to be adapted to all your projects.

You can download it: here