Interfacing of
IR receiver and IR Remote with an Arduino.
In this project, we will interface an IR Receiver and an IR
Remote with an Arduino and controls the output devices that is LED and Buzzer.
An IR Receiver is an electronic device that emit light
radiation and it receives the information in the form of light from IR Remote.
The received information from the IR remote send it to the Microcontroller.
There is various application of IR Receivers in day-to-day life like one used
in TV remotes. When we pressed any key on the remote it generates infrared signals,
IR receiver present in front of the TV receives that signal and send it to the
microcontroller for decoding after this controller gives the required output. And
also, main thing is it’s a wireless communication
Circuit Diagram:
Components Required:
§ Arduino
UNO
§ IR
Receiver
§ IR Remote
§ Red LED
§ Buzzer
§ Connecting
wires
Connection:
The
hardware a part of this project is quite simple and easy to place together.
First of all, make the connections for the IR Receiver with the Arduino. The
connections for the IR Receiver with the Arduino given in the above circuit
diagram.
IR Receiver
has three pins one is connected to the GND pin of an Arduino second pin is
connected to the VCC pin of an Arduino and output pin of IR receiver is
connected to the digital pin 10 of an Arduino.
Red
LEDs Anode pin is connected to the digital pin 2 of an Arduino and cathode is
connected to the GND Pin of an Arduino.
Buzzer positive pin is connected to the
digital pin 3 of an Arduino and negative pin is connected to the GND pin of an
Arduino Connect the one terminal of force sensor to the GND of an Arduino.
Basics of IR Communication
Infrared Communication or IR is using the Infrared Light.
Infrared Light has wavelength which is higher than the visible light. Hence
human being not able to see the Infrared Light.
This is the reason it is good choice for Wireless
Communication. But is has disadvantage that is line-of-sight error which means
for Communication between the transmitter and receiver both should be in one
line. Due to this reason IR communication cannot be used through walls.
IR Receiver
let us take a brief about the IR Receiver that we are using
here i.e.TSOP1838.
TSOP1838 is a very popular type of
IR receiver and its carrier frequency of 38kHZ. It has three pins namely: GND,
VCC and OUT.
The output of the TSOP 1838 IR Receiver
can be directly decoded by a microcontroller.
Working of project:
The working of the remote controlled led and buzzer project
is very simple. This project will demonstrate you how to interface IR Receiver
and an IR Remote with an Arduino.
Whenever key “1” is pressed then red LED will flash and when
the key “2” is pressed the buzzer will produce the sound. When we pressed the
any key on the IR remote that decodes by the Micro-controller. Each key on the
remote can be used for different task like turning on light, turn on motor etc.
Arduino
Code Explanation:
Include the IR Remote Library after
that define the output pin of IR Receiver it is connected to the pin 10 of an
Arduino.
Define
the LED and buzzer pins, led1 is connected to the pin 2 and buzzer is connected
to the pin 3 of an Arduino.
#include
<IRremote.h>
const
int RECV_PIN = 10;
IRrecv
irrecv(RECV_PIN);
decode_results
results;
int
led1=2;
int
buzzer=3;
Inside the
void setup we will define the pin which are input and which are output pin,
this set of code runs only once.
Initialize
the serial monitor for displaying the value at baud rate of 9600.
void
setup(){
Serial.begin(9600);
irrecv.enableIRIn();
irrecv.blink13(true);
pinMode(led1,OUTPUT);
pinMode(buzzer,OUTPUT);
}
the code
inside the void loop runs over and over as long as the Arduino Board is turned
on.
Here
inside the loop results.value stores the decoded code we can print that code on
serial monitor as hex code using Serial.println(results.value, HEX);
Now for
printing decimal value of the IR remote Key pressed for that we can use Serial.println(results.value);
void
loop(){
if (irrecv.decode(&results)){
Serial.println(results.value, HEX);
irrecv.resume();
Serial.println(results.value);
}
if (results.value==16582903)
{
digitalWrite(led1,HIGH);
delay(200);
digitalWrite(led1,LOW);
delay(200);
}
if (results.value==16615543)
{
digitalWrite(buzzer,HIGH);
delay(200);
digitalWrite(buzzer,LOW);
delay(200);
}
}
Here wehave used if() conditional
statement basic coding control
structures. One can make something happen or not, it depends whether the
condition is true or not. It looks like this:
When we pressed
the “1” key on the IR remote then Arduino gives us the decimal output which is
stored in results.value and the decimal output is 16582903.
If the if (results.value==16582903) then will create a led flashing
effect by turning it on and off.
Same thing
for the buzzer as well when we pressed the “2” key on the IR remote then
Arduino gives us the decimal output which is stored in results.value and the
decimal output for key 2 is 16615543.
If the if (results.value==16615543)then turn on the buzzer.
Watch the Working video:
Arduino
Sketch:
#include
<IRremote.h>
const
int RECV_PIN = 10;
IRrecv
irrecv(RECV_PIN);
decode_results
results;
int
led1=2;
int
buzzer=3;
void
setup(){
Serial.begin(9600);
irrecv.enableIRIn();
irrecv.blink13(true);
pinMode(led1,OUTPUT);
pinMode(buzzer,OUTPUT);
}
void
loop(){
if (irrecv.decode(&results)){
Serial.println(results.value, HEX);
irrecv.resume();
Serial.println(results.value);
}
if (results.value==16582903)
{
digitalWrite(led1,HIGH);
delay(200);
digitalWrite(led1,LOW);
delay(200);
}
if (results.value==16615543)
{
digitalWrite(buzzer,HIGH);
delay(200);
digitalWrite(buzzer,LOW);
delay(200);
}
}
Like share and comment :
Comments
Post a Comment
If you any query please comment