Controlling an Arduino Board Using an Infrared Remote Control

24,277

54

21

Posted

Introduction: Controlling an Arduino Board Using an Infrared Remote Control

I-Introduction
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 (http://arduino.cc/en/Main/Software)
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)

III-Instructions

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 (http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html), and unzip it in the Arduino libraries folder
Note:  you may have to change line
#include
to
#include
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.
*/



#include

#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);

  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
 
}

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

Share

Recommendations

  • Epilog Challenge 9

    Epilog Challenge 9
  • Sew Warm Contest 2018

    Sew Warm Contest 2018
  • Gluten Free Challenge

    Gluten Free Challenge
user

We have a be nice policy.
Please be positive and constructive.

Tips

Questions

21 Comments

the definition of the buttons would largely depend on the remote controller u r using

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
Serial.println(results.value);

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.

t

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.

Hi you resolved your problem finally ?

hello. please explain me in details what means:

Note: you may have to change line
#include
to
#include
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 https://github.com/shirriff/Arduino-IRremote ?
IRremote.h or IRremoteInt.h ? or maybe both? thanks :)

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

Sorry didn't see the 3 years ago...

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?

thanks