Arduino IR Remote Control

29,414

217

12

Introduction: Arduino IR Remote Control

Source: http://www.theorycircuit.com/arduino-universal-remote/

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;

}

break;

}

Serial.println(value); // you can comment this line

irrecv.resume(); // Receive the next value

}

}

Step 4: Prototype

Arduino All The Things! Contest

Participated in the
Arduino All The Things! Contest

4 People Made This Project!

Recommendations

  • The 1000th Contest

    The 1000th Contest
  • Battery Powered Contest

    Battery Powered Contest
  • Hand Tools Only Challenge

    Hand Tools Only Challenge

12 Discussions

0
hack_everything
hack_everything

4 years ago

can you use motors instead of leds?

0
theorycircuit
theorycircuit

Reply 4 years ago

Yes you can! but you should use ic L293D to drive motors.

Thank you

0
hack_everything
hack_everything

Reply 4 years ago

havent got the parts yet but there coming

0
hack_everything
hack_everything

Reply 4 years ago

thanks I will give it a go

0
rohit.mukherje
rohit.mukherje

Question 2 years ago on Step 1

I have a different remote ......its not working with the project ...? Any changes need to be done ?

0
Tanmay Deuskar
Tanmay Deuskar

4 years ago

Hello,

I am using a VS 1838 ir receiver. The receiver is working but when I press an button on my remote the serial monitor shows many HEX values for the same button. What can I do about that?

0
avishwakarma8
avishwakarma8

4 years ago

sir can u write code for 4 LED's plz

0
aayush swami
aayush swami

4 years ago

my code running perfect but serial monitor is showing garbage values without connecting TSOP1136 . But after connecting it does not takes any values in IRrecvDemo.ino

0
adithyapaip
adithyapaip

4 years ago

please help me...I am getting error saying fatal error WProgram.h no such file or directory....

temp_1996392104.jpg
0
manav786
manav786

4 years ago

my arduino hanged when ir remote was used after sometime.
it doesnt works whenever i'll press reset switch.
help plz.

0
manav786
manav786

4 years ago

my arduino hanged when ir remote was used after sometime.
it doesnt works whenever i'll press reset switch.
help plz.

0
Patel Trushang
Patel Trushang

4 years ago

hey i like your project. can you write code for 8 leds? please send to ptrushang@gmail.com