Summary of Arduino IR Remote Control
This article demonstrates how to decode infrared remote codes using an Arduino and an IR receiver (TSOP 1738). It details wiring the components, installing the IRremote library, capturing hex values, and controlling three LEDs based on specific remote button codes. The project enables users to build a custom remote-controlled switch system by mapping decoded signals to digital output pins.
Parts used in the Arduino IR Remote Control:
- Arduino board
- IR Receiver TSOP 1738
- IRremote library
- Three LEDs
- Digital output pins (2, 4, 6)
- Input pin for IR signal (Pin 11)
By using arduino and IR Receiver TSOP 1738 (in our project, you can use any ir receiver available) we can decode any infrared remote code into hex or some other format. Before constructing the circuit check datasheet of IR receiver having in your hand, hence you can connect proper bias pins and output pin.
Step 1: Wiring Components
To read the IR rays from remote control by arduino board we need external library that is IRremote library, you can get IRremote library here. (how to insert new library in arduino IDE)
Step 2: Receiving IR Hex Code
In this project first we have executed the IRrecvDemo example program from the arduino IR library example and decoded IR rays from remote.
(Note: If you have any error while running this library, remove “IRremoteTools.cpp” from libraries\RobotIRremote\IRremoteTools.cpp)
Arduino Code for Receiving IR as Hex code
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop(){
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value }
Step 3: Remote Control With Arduino
Then we used decoded data as switching condition in arduino sketch to turn on and off the three LEDs.
Arduino Code
#include <IRremote.h>
int RECV_PIN = 11; //
int output1 = 2;
int output2 = 4;
int output3 = 6;
int itsONled[] = {0,0,0,0};
#define code1 0xFF807F //
#define code2 0xFFA05F //
#define code3 0xFF906F //
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
Serial.begin(9600); //
irrecv.enableIRIn(); //
pinMode(output1, OUTPUT);
pinMode(output2, OUTPUT);
pinMode(output3, OUTPUT);
}
void loop() {
if (irrecv.decode(&results)) {
unsigned int value = results.value;
switch(value) {
case code1:
if(itsONled[1] == 1) { //
digitalWrite(output1, LOW); //
itsONled[1] = 0; // } else { //
digitalWrite(output1, HIGH); //
itsONled[1] = 1; //
}
break;
case code2:
if(itsONled[2] == 1) {
digitalWrite(output2, LOW);
itsONled[2] = 0; } else {
digitalWrite(output2, HIGH);
itsONled[2] = 1;
}
break;
case code3:
if(itsONled[3] == 1) {
digitalWrite(output3, LOW);
itsONled[3] = 0; } else {
digitalWrite(output3, HIGH);
itsONled[3] = 1;
Step 4: Prototype
Source: Arduino IR Remote Control
- What is required to read IR rays from a remote control by Arduino?
You need an external library called the IRremote library. - How can I decode any infrared remote code into hex format?
Use an Arduino with an IR receiver like the TSOP 1738 to execute the IRrecvDemo program. - Which library example should be executed first to decode IR rays?
Execute the IRrecvDemo example program from the Arduino IR library. - What should I do if I get an error while running the library?
Remove the file IRremoteTools.cpp from librariesRobotIRremoteIRremoteTools.cpp. - Can I use any IR receiver available for this project?
Yes, you can use any IR receiver available, but you must check its datasheet first. - How are the decoded data used in the sketch to control devices?
The decoded data serves as switching conditions to turn on and off three LEDs. - What defines the specific codes for turning the LEDs on or off?
The codes are defined as constants like 0xFF807F, 0xFFA05F, and 0xFF906F. - Which pins are assigned for the three LED outputs?
Pins 2, 4, and 6 are assigned for the three LED outputs.
