Controlling an Arduino Board Using an Infrared Remote Control

Introduction: Controlling an Arduino Board Using an Infrared Remote Control

Hello everyone, my name is Noreddine Kessa, I am an electronics enthusiast.  I had fun this weekend playing with my new toy ,  Arduino ATmega328 DIY Kit that I got on eBay, and I would love to share the joy with everyone interested in learning about the subject. OK enough of that,  let us dive right in, my project is to remotely control three Digital channels using an infrared remote control,   basically I will show you how to use a remote control to control an Arduino board which in turn can be used to control a device,  a robot , or  some type of gadget that you wish to remotely  control.

II-Bill Of Materials

1X  Arduino board,
1X Computer Loaded with Arduino compiler (you can download it on (
1X USB cable
1X 9 Volt Power supply (optional, you can use you computer  USB as power source)
1X infrared remote control (Model : Car mp3)
3X  LEDs
3X 330 Ohm resistors
Connecting wires(as needed)
1X  infrared receiver (Model PNA4602 )
1X breadboard 
1X Multimeter(Optional)


Note: you can use any remote control or infrared receiver, I just listed what I used in this project
Step1: download the infrared library from (, and unzip it in the Arduino libraries folder
Note:  you may have to change line
in  the header file “Irremoteint.h”  .

Step 2: connect the IR receiver LEDs and instructed below, use picture for  reference
*************LEDs and resistors connections***************
a)connect the Cathode of all three LEDs to Arduino Ground
b)connect one end of resistor R1 to LED1 anode
c)connect the  other end of resistor R1 to pin 9 of the Arduino board
d)connect one end of resistor R2 to LED2 anode
e)connect the  other end of resistor R2 to pin 11 of the Arduino board
f)connect one end of resistor R3 to LED3 anode
g)connect the  other end of resistor R3 to pin 12 of the Arduino board 
*************Infrared receiver connections***************
  h)connect pin 1 of the IR receiver to 5Volt supply from the Arduino board
  i)connect pin 2 of the IR receiver to ground of the Arduino board
  j)connect pin 3 of the IR receiver to pin  10 of the Arduino board
Step 3: connect the Computer to the Arduino board using a USB cable.
Step 3: 
a) open Arduino Compiler
b) start a new project
c) copy the source code at the end of this tutorial to the compiler editor, then upload the program to the Arduino board
Step4: now you are ready to test your project
a) use button 1 to turn LED1 on
b) use button 2 to turn LED2 on
c) use button 3 to turn LED3 on
d) use button 4 to turn LED1 off  
e) use button 5 to turn LED2 off
f) use button 6 to turn LED3 off
g) use button 7 for all three LEDs to flash on and off

I hope you enjoyed my tutorial. you are free to modify the code as you wish for your personal application.

/*****************Code Starts Here***********************

Author: Noreddine Kessa
Date : 15 jan 2012
Project: Infrared program arduino board:
Purpose: Controle an arduino IO board using a remote control.


#define button1 16724175
#define button2 16718055
#define button3 16743045
#define button4 16716015
#define button5 16726215
#define button6 16734885
#define button7 16728765
#define button8 16730805
#define LED1  11
#define LED2  12
#define LED3  9
#define RECV_PIN  10
#define del 50
#define flashNumber 100

int times ;
IRrecv irrecv(RECV_PIN);
decode_results results;
long lReceived = 0 ;

void setup()
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
  pinMode(RECV_PIN , INPUT);

  irrecv.enableIRIn(); // Start the receiver

void loop() {
  if (irrecv.decode(&results)) {
    lReceived = results.value ;
      switch (lReceived) {
    case button1:
      digitalWrite (LED1, HIGH);
    case button4:
       digitalWrite(LED1, LOW);
    case button2:
      digitalWrite( LED2, HIGH);
    case button5:
       digitalWrite(LED2, LOW);
    case button3:
      digitalWrite (LED3, HIGH);
    case button6:
       digitalWrite(LED3, LOW);
     case button7:
       times = flashNumber;
flash :
       digitalWrite (LED1, LOW);
       digitalWrite (LED2, LOW);
       digitalWrite (LED3, LOW);
        if (!(times--))
         goto brk ;
       digitalWrite (LED1, HIGH);
       digitalWrite (LED1, LOW);
       digitalWrite (LED2, HIGH);
       digitalWrite (LED2, LOW);
       digitalWrite (LED3, HIGH);
       goto flash ;
    irrecv.resume(); // Receive the next value
//*****************Code Ends  Here***********************



    • Furniture Contest 2018

      Furniture Contest 2018
    • Metalworking Contest

      Metalworking Contest
    • Audio Contest 2018

      Audio Contest 2018

    21 Discussions

    yes, that is correct,
    those button definition only apply to remote control model Car mp3, other remote controls would have different numbers.

    do find out what the definition number for your specific remote control, after you program your arduino board, keep it connected to computer and open the terminal app in the arduino compiler, every time you push a button you will see that buttons code in the terminal window.

    this is done by the line

    I am very very new to electronics (beginner/hobby only) and from a very different profession. I have made this working by typing #include "Irremote.h" and NOT "Irremoteint.h". Since electronics is only a hobby of mine I cannot guarantee for anything so try anything at your own risk.


    @Gabriel T48... no i m not getting it no still not

    I am new to this! I liked ur instructible. But i want ti contril RC car buy using arduino uno. I want to replace rx tx of rc car and make use of ardiuno and tv remote. So that when i press a button on remote the car will move forward and when i release button the car will stop. This should be on off process and when i release button it should stop. How can i do it? Please suggest.

    1 reply

    hello. please explain me in details what means:

    Note: you may have to change line
    in the header file “Irremoteint.h” .

    what i have to change? and where? i dont get it. maybe my english is too bad.

    and which library i must download from here ?
    IRremote.h or IRremoteInt.h ? or maybe both? thanks :)

    2 replies

    You need to change "#include" to "#include Irremoteint.h", or at least that's what I understand from other comments.

    is there is any opontion where I can reverse the effect when I unpress the button

    for example can I somehow make the leds turn on when I press the button and pff when I remove my finger?


    I believe it would be most helpful for you to upload the .ino file to your instructable rather than just relying on copy/paste. Cheers.

    Do you know how it is possible that the code is not correct, this sentence does not fit: IRrecv irrecv(receiver); // create instance of 'irrecv'

    Do you have a solution?

    3 replies

    remeber to #include Irremoteint.h at the top of source code, for some reason it was omitted from the code i posted

    I treid this code and it did work for me, the only thing that i noticed missing from the source code when i posted it on this site was the first #include is the library and it was omitted because of the grather than and less than signs.

    All you need to do is upload the source code above to your Arduino, and connect to the Arduino using a terminal program. You can use either TeraTerm, or the built in terminal program in Arduino IDE, if all your hardware is connected properly, once a button is pressed, you will see the value that corresponds to that button on the terminal program.
    This value is output using this line
    I Hope This helps

    Do you know if it can work with that led-like phototransistor that outputs a signal that the arduino can read only in the analog inputs?

    Hi, I am new to arduino and and when using this code I receive this error message:
    _3lights.cpp: In function 'void loop()':
    _3lights:52: error: 'FD08F7' was not declared in this scope
    _3lights:56: error: 'FD28D7' was not declared in this scope
    _3lights:60: error: 'FD8877' was not declared in this scope
    _3lights:64: error: 'FDA857' was not declared in this scope
    _3lights:68: error: 'FD48B7' was not declared in this scope
    _3lights:72: error: 'FD6897' was not declared in this scope
    _3lights:76: error: 'FD18E7' was not declared in this scope

    Maybe a library issue? I only changed the first few lines:

    #define button1 FD08F7
    #define button2 FD8877
    #define button3 FD48B7
    #define button4 FD28D7
    #define button5 FDA857
    #define button6 FD6897
    #define button7 FD18E7
    #define button8 FD9867
    #define LED1 11
    #define LED2 12
    #define LED3 9
    #define RECV_PIN 10
    #define del 50
    #define flashNumber 100

    This is the code I used to decode my remote:

    const int RECV_PIN = 10;

    IRrecv irrecv(RECV_PIN);

    decode_results results;

    void setup()
    irrecv.enableIRIn(); // Start the receiver

    void loop() {
    if (irrecv.decode(&results)) {
    if (results.decode_type == NEC) {
    Serial.print("NEC: ");
    } else if (results.decode_type == SONY) {
    Serial.print("SONY: ");
    } else if (results.decode_type == RC5) {
    Serial.print("RC5: ");
    } else if (results.decode_type == RC6) {
    Serial.print("RC6: ");
    } else if (results.decode_type == UNKNOWN) {
    Serial.print("UNKNOWN: ");
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value

    1 reply

    This is a little late to help you rye_guy, but I think you need to prefix each of those codes with 0x to indicate that it's a binary value... Otherwise your sketch thinks its a variable which you have not declared.

    Hopefully that helps someone else.