0% found this document useful (0 votes)
53 views

Arduino IR Remort Sensor

This document describes a project to control 3 LEDs using an infrared receiver and an Arduino board. The receiver is used to detect button presses on a remote control and corresponding codes are mapped to turning individual LEDs on and off.

Uploaded by

EE 503 AnAs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

Arduino IR Remort Sensor

This document describes a project to control 3 LEDs using an infrared receiver and an Arduino board. The receiver is used to detect button presses on a remote control and corresponding codes are mapped to turning individual LEDs on and off.

Uploaded by

EE 503 AnAs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Arduino – Control LEDs with IR Remote Control

In this project you’ll use an infrared (IR) receiver and an Arduino to control 3 LEDs with a remote control. This is
useful to re-use old remote controls or give some functionally to some of your remote’s buttons.

This project is divided into two parts:

1. You’ll decode the IR signals transmitted by your remote control


2. You’ll use that info to perform a task with your Arduino (control 3 LEDs)

Parts required
To follow this project you need the following parts:
 Arduino UNO – read Best Arduino Starter Kits
 1x Breadboard
 1x Remote control
 1x IR receiver ( I’ll be using TSOP4838)
 3x LED’s
 3x 220 Ohm resistors
 Jumper wires

Introducing the Infrared (IR) Receiver


The infrared receiver is the component shown in the figure below. This is the TSOP4838.
Infrared receiver pins:
 First pin: Vout
 Second pin: GND
 Third pin: Vcc
When you press your remote control, it sends infrared modulated signals. These signals contain information that your
receiver collects.

Each button sends specific information. So, we can assign that information to a specific button.

Decode the IR signals


In this part of the project you need to decode the IR signals associated with each button.

Schematics
Connect the IR receiver accordingly to the schematics below.
Code
To control the IR receiver, you need to install the IRremote Library  in the Arduino IDE.

Copy the following code to your Arduino IDE, and upload it to your Arduino board. Make sure that you have the right
board and COM port selected.

/*
* IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
* An IR detector/demodulator must be connected to the input RECV_PIN.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
*/

#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
}
delay(100);
}

Open the serial monitor at a baud rate of 9600.

In this project you want to control 3 LEDs. Choose 6 buttons for the following tasks:

1. LED1 – ON
2. LED1 – OFF
3. LED2 – ON
4. LED2 – OFF
5. LED3 – ON
6. LED3 – OFF
Press, for example, the button number 1 of your remote control. You should see a code on the serial monitor. Press
the same button several times to make sure you have the right code for that button. If you see something like
FFFFFFFF ignore it, it’s trash.

Do the same for the other buttons.

Write down the code associated with each button, because you’ll need that information later.
Building the final circuit
In this part, you’ll build the circuit with three LEDs that will be controlled using your remote.

Schematics
Assemble all the parts by following the schematics below.
Code
Now, grab the codes you captured in the previous step. You need to convert your codes from hex to decimal.

For that, you can use the following website: www.binaryhexconverter.com/hex-to-decimal-converter


Here’s a conversion example for one of my codes:
Repeat that process to all your hex values and save the decimal values. These are the ones you need to replace in
the code below.
Download or copy the following sketch to your Arduino IDE. Write your own decimal values in the sketch
provided in the case lines and upload it to your Arduino board. Make sure that you have the right board and COM
port selected

/*
* Modified by Rui Santos, http://randomnerdtutorialscom
* based on IRremote Library - Ken Shirriff
*/

#include <IRremote.h>

int IR_Recv = 11; //IR Receiver Pin 3


int bluePin = 10;
int greenPin = 9;
int yellowPin = 8;

IRrecv irrecv(IR_Recv);
decode_results results;

void setup(){
Serial.begin(9600); //starts serial communication
irrecv.enableIRIn(); // Starts the receiver
pinMode(bluePin, OUTPUT); // sets the digital pin as output
pinMode(greenPin, OUTPUT); // sets the digital pin as output
pinMode(yellowPin, OUTPUT); // sets the digital pin as output

void loop(){
//decodes the infrared input
if (irrecv.decode(&results)){
long int decCode = results.value;
Serial.println(results.value);
//switch case to use the selected remote control button
switch (results.value){
case 551520375: //when you press the 1 button
digitalWrite(bluePin, HIGH);
break;
case 551495895: //when you press the 4 button
digitalWrite(bluePin, LOW);
break;
case 551504055: //when you press the 2 button
digitalWrite(greenPin, HIGH);
break;
case 551528535: //when you press the 5 button
digitalWrite(greenPin, LOW);
break;
case 551536695: //when you press the 3 button
digitalWrite(yellowPin, HIGH);
break;
case 551512215: //when you press the 6 button
digitalWrite(yellowPin, LOW);
break;
}
irrecv.resume(); // Receives the next value from the button you press
}
delay(10);
}
Demonstration
In the end you can control each LED individually using the buttons of your remote control.

You might also like