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***********************

Participated in the
Arduino Challenge
20 Comments
11 years ago on Introduction
the definition of the buttons would largely depend on the remote controller u r using
Reply 11 years ago on Introduction
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);
6 years ago
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
7 years ago
@Gabriel T48... no i m not getting it no still not
8 years ago
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.
Reply 7 years ago
Hi you resolved your problem finally ?
10 years ago on Introduction
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 :)
Reply 8 years ago
You need to change "#include" to "#include Irremoteint.h", or at least that's what I understand from other comments.
Reply 8 years ago
Sorry didn't see the 3 years ago...
8 years ago on Introduction
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
9 years ago on Introduction
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?
Reply 9 years ago on Introduction
i m also facing the same problem.......
Reply 9 years ago on Introduction
remeber to #include Irremoteint.h at the top of source code, for some reason it was omitted from the code i posted
Reply 9 years ago on Introduction
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.
9 years ago on Introduction
how to find the button defination can u guys please help in learning about RC5
Reply 9 years ago on Introduction
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
Serial.println(results.value);
I Hope This helps
9 years ago on Introduction
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?
11 years ago on Introduction
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:
#include
#include
#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:
#include
const int RECV_PIN = 10;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
irrecv.blink13(true);
}
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
}
}
Reply 9 years ago on Introduction
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.
11 years ago on Introduction
#include "IRremote.h"
#include "IRremoteInt.h"
and
#include "IRremote.h", in the last part
sorry, didn't show up in the original brackets...