SlideShare a Scribd company logo
Tag Archive | "TSOP4138"
Tutorial: Arduino and Infra-red control
Posted on 30 March 2011. Tags: 38kHz, arduino, command, control, DFR0094, DFR0107, dfrobot,
DIY, duemilanove, education, guide, guides, i2c, infra, infrared, IR, LCD, learn, lesson, lessons,
project, receive, red, send, system, tronixstuff, TSOP4138, tutorial, tutorials, uno, Vishay
Learn how to use Arduino and infra-red remote controls in chapter thirty-two of a series originally
titled “Getting Started/Moving Forward with Arduino!” by John Boxall – A tutorial on the Arduino
universe. The first chapter is here, the complete series is detailed here.
Updated 10/07/2013
In this article we will look at something different to the usual, and hopefully very interesting and useful
– interfacing our Arduino systems with infra-red receivers. Why would we want to do this? To have
another method to control our Ardiuno-based systems, using simple infra-red remote controls.
A goal of this article is to make things as easy as possible, so we will not look into the base detail of
how things work - instead we will examine how to get things done. If you would like a full explanation
of infra-red, perhaps see the page on Wikipedia. The remote controls you use for televisions and so on
transmit infra-red beam which is turned on and off at a very high speed – usually 38 kHz, to create bits
of serial data which are then interpreted by the receiving unit. As the wavelength of infra-red light is
too high for human eyes, we cannot see it. However using a digital camera – we can. Here is a
demonstration video of IR codes being sent via a particularly fun kit – the adafruit TV-B-Gone:
Now to get started. You will need a remote control, and a matching IR receiver device. The hardware
and library used in this tutorial only supports NEC, Sony SIRC, Philips RC5, Philips RC6, and raw IR
protocols. Or you can purchase a matching set for a good price, such as this example:
Or you may already have a spare remote laying around somewhere. I kept this example from my old
Sony Trinitron CRT TV after it passed away:
It will more than suffice for a test remote. Now for a receiver – if you have purchased the
remote/receiver set, you have a nice unit that is ready to be wired into your Arduino, and also a great
remote that is compact and easy to carry about. To connect your receiver module – as per the PCB
labels, connect Vcc to Arduino 5V, GND to Arduino GND, and D (the data line) to Arduino digital pin
11.
Our examples use pin 11, however you can alter that later on. If you are using your own remote control,
you will just need a receiver module. These are very cheap, and an ideal unit is the Vishay TSOP4138
(data sheet .pdf). These are available from element-14 and the other usual retail suspects. They are also
dead-simple to use. Looking at the following example:
From left to right the pins are data, GND and Vcc (to Arduino +5V). So it can be easily wired into a
small breadboard for testing purposes. Once you have your remote and receiver module connected, you
need to take care of the software side of things. There is a new library to download and install,
download it from here. Please note that library doesn’t work for Arduino Leonardo, Freetronics
Leostick, etc with ATmega32U4. Instead, use this library (and skip the modification steps below).
Extract the IRremote folder and place into the ..arduinoxxxlibraries folder. Then restart your Arduino
IDE if it was already open.
Using Arduino IDE v1.0 or greater? Open the file “IRRemoteInt.h” in the library folder, and change
the line
#include "WProgram.h"
to
#include "Arduino.h"
1
2
3
4
#include "WProgram.h"
to
#include "Arduino.h"
Then save and close the file, restart the Arduino IDE and you’re set.
With our first example, we will receive the commands from our remote control and display them on the
serial monitor:
// example 32.1 - IR receiver code repeater
// http://tronixstuff.com/tutorials > chapter 32
// based on code by Ken Shirriff - http://arcfn.com
#include <IRremote.h> // use the library
int receiver = 11; // pin 1 of IR receiver to Arduino digital pin 11
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results;
void setup()
{
Serial.begin(9600); // for serial monitor output
irrecv.enableIRIn(); // Start the receiver
}
void loop()
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
Serial.println(results.value, HEX); // display it on serial monitor in hexadecimal
irrecv.resume(); // receive the next value
} // Your loop can do other things while waiting for an IR command
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// example 32.1 - IR receiver code repeater
// http://tronixstuff.com/tutorials > chapter 32
// based on code by Ken Shirriff - http://arcfn.com
#include <IRremote.h> // use the library
int receiver = 11; // pin 1 of IR receiver to Arduino digital pin 11
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results;
void setup()
{
Serial.begin(9600); // for serial monitor output
irrecv.enableIRIn(); // Start the receiver
}
void loop()
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
Serial.println(results.value, HEX); // display it on serial monitor in hexadecimal
irrecv.resume(); // receive the next value
} // Your loop can do other things while waiting for an IR command
}
Open the serial monitor box, point your remote control to the receiver and start pressing away. You
should see something like this:
What have we here? Lots of hexadecimal numbers. Did you notice that each button on your remote
control resulted in an individual hexadecimal number? I hope so. The number FFFFFFFF means that
the button was held down. The remote used was from a yum-cha discount TV. Now I will try again
with the Sony remote:
This time, each button press resulted in the same code three times. This is peculiar to Sony IR systems.
However nothing to worry about. Looking back at the sketch for example 32.1, the
1 if (irrecv.decode(&results))
section is critical – if a code has been received, the code within the if statement is executed. The
hexadecimal code is stored in the variable
1 results.value
with which we can treat as any normal hexadecimal number. At this point, press a few buttons on your
remote control, and take a note of the matching hexadecimal codes that relate to each button. We will
need these codes for the next example…
Now we know how to convert the infra-red magic into numbers, we can create sketches to have our
Arduino act on particular commands. As the IR library returns hexadecimal numbers, we can use
simple decision functions to take action. In the following example, we use switch…case to examine
each inbound code, then execute a function. In this case we have an LCD module connected via I2C,
and the sketch is programmed to understand fifteen Sony IR codes. If you don’t have an LCD you
could always send the output to the serial monitor. If you are using the DFRobot I2C LCD display, you
need to use Arduino v23.
Furthermore you can substitute your own values if not using Sony remote controls. Finally, this sketch
has a short loop after the translateIR(); function call which ignores the following two codes – we do
this as Sony remotes send the same code three times. Again. you can remove this if necessary. Note
that when using hexadecimal numbers in our sketch we preced them with 0x:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// example 32.2 - IR receiver code translator
// for Sony IR codes (ignores 2nd and 3rd signal repeat)
// http://tronixstuff.com/tutorials > chapter 32
// based on code by Ken Shirriff - http://arcfn.com
#include "Wire.h" // for I2C bus
#include "LiquidCrystal_I2C.h" // for I2C bus LCD module
(http://www.dfrobot.com/wiki/index.php/I2C/TWI_LCD1602_Module_(SKU:_DFR0063))
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
#include <IRremote.h> // use the library for IR
int receiver = 11; // pin 1 of IR receiver to Arduino digital pin 11
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results;
void setup()
{
lcd.init(); // initialize the lcd
lcd.backlight(); // turn on LCD backlight
irrecv.enableIRIn(); // Start the receiver
}
void translateIR() // takes action based on IR code received
// describing Sony IR codes on LCD module
{
switch(results.value)
{
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
case 0x37EE: lcd.println(" Favourite "); break;
case 0xA90: lcd.println(" Power button "); break;
case 0x290: lcd.println(" mute "); break;
case 0x10: lcd.println(" one "); break;
case 0x810: lcd.println(" two "); break;
case 0x410: lcd.println(" three "); break;
case 0xC10: lcd.println(" four "); break;
case 0x210: lcd.println(" five "); break;
case 0xA10: lcd.println(" six "); break;
case 0x610: lcd.println(" seven "); break;
case 0xE10: lcd.println(" eight "); break;
case 0x110: lcd.println(" nine "); break;
case 0x910: lcd.println(" zero "); break;
case 0x490: lcd.println(" volume up "); break;
case 0xC90: lcd.println(" volume down "); break;
case 0x90: lcd.println(" channel up "); break;
case 0x890: lcd.println(" channel down "); break;
default: lcd.println(" other button ");
}
delay(500);
lcd.clear();
}
void loop()
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
translateIR();
for (int z=0; z<2; z++) // ignore 2nd and 3rd signal repeat
{
irrecv.resume(); // receive the next value
}
}
}
And here it is in action:
You might be thinking “why would I want to make things appear on the LCD like that?”. The purpose
of the example is to show how to react to various IR commands. You can replace the LCD display
functions with other functions of your choosing.
At the start working with infra-red may have seemed to be complex, but with the previous two
examples it should be quite simple by now. So there you have it, another useful way to control our
Arduino systems. Hopefully you have some ideas on how to make use of this technology. In future
articles we will examine creating and sending IR codes from our Arduino. Furthermore, a big thanks to
Ken Shirriff for his Arduino library.
Have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+,
subscribe for email updates or RSS using the links on the right-hand column, or join our Google
Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each
other – and we can all learn something.
Arduino Tutorials
Click for Detailed Chapter Index
Chapters 0 1 2 3 4
Chapters 5 6 6a 7 8
Chapters 9 10 11 12 13
Ch. 14 - XBee
Ch. 15 - RFID - RDM-630
Ch. 15a - RFID - ID-20
Ch. 16 - Ethernet
Ch. 17 - GPS - EM406A
Ch. 18 - RGB matrix - awaiting update
Ch. 19 - GPS - MediaTek 3329
Ch. 20 - I2C bus part I
Ch. 21 - I2C bus part II
Ch. 22 - AREF pin
Ch. 23 - Touch screen
Ch. 24 - Monochrome LCD
Ch. 25 - Analog buttons
Ch. 26 - GSM - SM5100 Uno
Ch. 27 - GSM - SM5100 Mega
Ch. 28 - Colour LCD
Ch. 29 - TFT LCD touch screen
Ch. 30 - Arduino + twitter
Ch. 31 - Inbuilt EEPROM
Ch. 32 - Infra-red control
Ch. 33 - Control AC via SMS
Ch. 34 - SPI bus part I
Ch. 35 - Video-out
Ch. 36 - SPI bus part II
Ch. 37 - Timing with millis()
Ch. 38 - Thermal Printer
Ch. 39 - NXP SAA1064
Ch. 40 - Push wheel switches
Ch. 40a - Wheel switches II
Ch. 41 - More digital I/O
Ch. 42 - Numeric keypads
Ch. 43 - Port Manipulation - Uno
Ch. 44 - ATtiny+Arduino
Ch. 45 - Ultrasonic Sensor
Ch. 46 - Analog + buttons II
Ch. 47 - Internet-controlled relays
Ch. 48 - MSGEQ7 Spectrum Analyzer
First look - Arduino Due
Ch. 49 - KTM-S1201 LCD modules
Ch. 50 - ILI9325 colour TFT LCD modules
Ch. 51 - MC14489 LED display driver IC
Ch. 52 - NXP PCF8591 ADC/DAC IC
Ch. 53 - TI ADS1110 16-bit ADC IC
Ch. 54 - NXP PCF8563 RTC
Ch. 55 - GSM - SIM900
Ch. 56 - MAX7219 LED driver IC
Ch. 57 - TI TLC5940 LED driver IC
Ch. 58 - Serial PCF8574 LCD Backpacks
Arduino Yún tutorials
pcDuino tutorials
The Arduino Book
Interesting Sites
David L. Jones' eev blog
Freetronics Arduino Geniuses!
Silicon Chip magazine Always a great read!
Talking Electronics
Amazing Arduino Shield Directory
Dangerous Prototypes
The Amp Hour podcast
EEWeb Elec Engineering Forum
Superhouse.tv High-tech home renovation
Mr Dick Smith OA
.

More Related Content

What's hot

Arduino spooky projects_class3
Arduino spooky projects_class3Arduino spooky projects_class3
Arduino spooky projects_class3
Anil Yadav
 
Advanced view arduino projects list use arduino for projects (4)
Advanced view arduino projects list   use arduino for projects (4)Advanced view arduino projects list   use arduino for projects (4)
Advanced view arduino projects list use arduino for projects (4)
WiseNaeem
 
LinnStrument : the ultimate open-source hacker instrument
LinnStrument : the ultimate open-source hacker instrumentLinnStrument : the ultimate open-source hacker instrument
LinnStrument : the ultimate open-source hacker instrument
Geert Bevin
 
Arduino tutorial A to Z
Arduino tutorial A to ZArduino tutorial A to Z
Arduino tutorial A to Z
Md. Asaduzzaman Jabin
 
Arduino Introduction by coopermaa
Arduino Introduction by coopermaaArduino Introduction by coopermaa
Arduino Introduction by coopermaa
馬 萬圳
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digital
Tony Olsson.
 
Arduino Workshop
Arduino WorkshopArduino Workshop
Arduino Workshop
atuline
 
Physical prototyping lab1-input_output (2)
Physical prototyping lab1-input_output (2)Physical prototyping lab1-input_output (2)
Physical prototyping lab1-input_output (2)
Tony Olsson.
 
Arduino Lecture 4 - Interactive Media CS4062 Semester 2 2009
Arduino Lecture 4 - Interactive Media CS4062 Semester 2 2009Arduino Lecture 4 - Interactive Media CS4062 Semester 2 2009
Arduino Lecture 4 - Interactive Media CS4062 Semester 2 2009
Eoin Brazil
 
Advanced view arduino projects list use arduino for projects (5)
Advanced view arduino projects list   use arduino for projects (5)Advanced view arduino projects list   use arduino for projects (5)
Advanced view arduino projects list use arduino for projects (5)
WiseNaeem
 
Getting startedwitharduino ch04
Getting startedwitharduino ch04Getting startedwitharduino ch04
Getting startedwitharduino ch04
Anil Yadav
 
Cassiopeia Ltd - standard Arduino workshop
Cassiopeia Ltd - standard Arduino workshopCassiopeia Ltd - standard Arduino workshop
Cassiopeia Ltd - standard Arduino workshop
tomtobback
 
Advanced view arduino projects list use arduino for projects
Advanced view arduino projects list   use arduino for projectsAdvanced view arduino projects list   use arduino for projects
Advanced view arduino projects list use arduino for projects
WiseNaeem
 
Intro to Arduino
Intro to ArduinoIntro to Arduino
Intro to Arduino
Qtechknow
 
Advanced view of atmega microcontroller projects list 1649 at mega32 avr
Advanced view of atmega microcontroller projects list 1649  at mega32 avrAdvanced view of atmega microcontroller projects list 1649  at mega32 avr
Advanced view of atmega microcontroller projects list 1649 at mega32 avr
WiseNaeem
 
Introduction to the Arduino
Introduction to the ArduinoIntroduction to the Arduino
Introduction to the Arduino
Wingston
 
IOTC08 The Arduino Platform
IOTC08 The Arduino PlatformIOTC08 The Arduino Platform
IOTC08 The Arduino Platform
Eoin Brazil
 
Physical prototyping lab3-serious_serial
Physical prototyping lab3-serious_serialPhysical prototyping lab3-serious_serial
Physical prototyping lab3-serious_serial
Tony Olsson.
 
Advanced view pic microcontroller projects list pic microcontroller
Advanced view pic microcontroller projects list   pic microcontrollerAdvanced view pic microcontroller projects list   pic microcontroller
Advanced view pic microcontroller projects list pic microcontroller
WiseNaeem
 
Advanced view of projects raspberry pi list raspberry pi projects
Advanced view of projects raspberry pi list   raspberry pi projectsAdvanced view of projects raspberry pi list   raspberry pi projects
Advanced view of projects raspberry pi list raspberry pi projects
WiseNaeem
 

What's hot (20)

Arduino spooky projects_class3
Arduino spooky projects_class3Arduino spooky projects_class3
Arduino spooky projects_class3
 
Advanced view arduino projects list use arduino for projects (4)
Advanced view arduino projects list   use arduino for projects (4)Advanced view arduino projects list   use arduino for projects (4)
Advanced view arduino projects list use arduino for projects (4)
 
LinnStrument : the ultimate open-source hacker instrument
LinnStrument : the ultimate open-source hacker instrumentLinnStrument : the ultimate open-source hacker instrument
LinnStrument : the ultimate open-source hacker instrument
 
Arduino tutorial A to Z
Arduino tutorial A to ZArduino tutorial A to Z
Arduino tutorial A to Z
 
Arduino Introduction by coopermaa
Arduino Introduction by coopermaaArduino Introduction by coopermaa
Arduino Introduction by coopermaa
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digital
 
Arduino Workshop
Arduino WorkshopArduino Workshop
Arduino Workshop
 
Physical prototyping lab1-input_output (2)
Physical prototyping lab1-input_output (2)Physical prototyping lab1-input_output (2)
Physical prototyping lab1-input_output (2)
 
Arduino Lecture 4 - Interactive Media CS4062 Semester 2 2009
Arduino Lecture 4 - Interactive Media CS4062 Semester 2 2009Arduino Lecture 4 - Interactive Media CS4062 Semester 2 2009
Arduino Lecture 4 - Interactive Media CS4062 Semester 2 2009
 
Advanced view arduino projects list use arduino for projects (5)
Advanced view arduino projects list   use arduino for projects (5)Advanced view arduino projects list   use arduino for projects (5)
Advanced view arduino projects list use arduino for projects (5)
 
Getting startedwitharduino ch04
Getting startedwitharduino ch04Getting startedwitharduino ch04
Getting startedwitharduino ch04
 
Cassiopeia Ltd - standard Arduino workshop
Cassiopeia Ltd - standard Arduino workshopCassiopeia Ltd - standard Arduino workshop
Cassiopeia Ltd - standard Arduino workshop
 
Advanced view arduino projects list use arduino for projects
Advanced view arduino projects list   use arduino for projectsAdvanced view arduino projects list   use arduino for projects
Advanced view arduino projects list use arduino for projects
 
Intro to Arduino
Intro to ArduinoIntro to Arduino
Intro to Arduino
 
Advanced view of atmega microcontroller projects list 1649 at mega32 avr
Advanced view of atmega microcontroller projects list 1649  at mega32 avrAdvanced view of atmega microcontroller projects list 1649  at mega32 avr
Advanced view of atmega microcontroller projects list 1649 at mega32 avr
 
Introduction to the Arduino
Introduction to the ArduinoIntroduction to the Arduino
Introduction to the Arduino
 
IOTC08 The Arduino Platform
IOTC08 The Arduino PlatformIOTC08 The Arduino Platform
IOTC08 The Arduino Platform
 
Physical prototyping lab3-serious_serial
Physical prototyping lab3-serious_serialPhysical prototyping lab3-serious_serial
Physical prototyping lab3-serious_serial
 
Advanced view pic microcontroller projects list pic microcontroller
Advanced view pic microcontroller projects list   pic microcontrollerAdvanced view pic microcontroller projects list   pic microcontroller
Advanced view pic microcontroller projects list pic microcontroller
 
Advanced view of projects raspberry pi list raspberry pi projects
Advanced view of projects raspberry pi list   raspberry pi projectsAdvanced view of projects raspberry pi list   raspberry pi projects
Advanced view of projects raspberry pi list raspberry pi projects
 

Viewers also liked

Constant Current Regulator for Driving LEDs
Constant Current Regulator for Driving LEDsConstant Current Regulator for Driving LEDs
Constant Current Regulator for Driving LEDs
Premier Farnell
 
Remote ac power control by android application with lcd display
Remote ac power control by android application with lcd displayRemote ac power control by android application with lcd display
Remote ac power control by android application with lcd display
Edgefxkits & Solutions
 
Automatic traffic density monitoring and control system
Automatic traffic density monitoring and control systemAutomatic traffic density monitoring and control system
Automatic traffic density monitoring and control system
Shubham Kulshreshtha
 
Final Presentation - Edan&Itzik
Final Presentation - Edan&ItzikFinal Presentation - Edan&Itzik
Final Presentation - Edan&Itzik
itzik cohen
 
OpenEnergyMonitor: Univeristy of Turin GreenTo Build Workshop
OpenEnergyMonitor: Univeristy of Turin GreenTo Build WorkshopOpenEnergyMonitor: Univeristy of Turin GreenTo Build Workshop
OpenEnergyMonitor: Univeristy of Turin GreenTo Build Workshop
OpenEnergyMonitor
 
Single phase ac voltage controller
Single phase ac voltage controllerSingle phase ac voltage controller
Single phase ac voltage controller
Swati Tiwari
 
Security system using Arduino
Security system using ArduinoSecurity system using Arduino
Security system using Arduino
Apoorv Anand
 
Thyristors,Commutayion of Thyristor, Power Electronics
Thyristors,Commutayion of Thyristor, Power ElectronicsThyristors,Commutayion of Thyristor, Power Electronics
Thyristors,Commutayion of Thyristor, Power Electronics
Durgesh Singh
 
"Automatic Intelligent Plant Irrigation System using Arduino and GSM board"
"Automatic Intelligent Plant Irrigation System using Arduino and GSM board""Automatic Intelligent Plant Irrigation System using Arduino and GSM board"
"Automatic Intelligent Plant Irrigation System using Arduino and GSM board"
Disha Modi
 
Home automation & security system
Home automation & security systemHome automation & security system
Home automation & security system
Aniket Maithani
 
HOME AUTOMATION USING ARDUINO
HOME AUTOMATION USING ARDUINOHOME AUTOMATION USING ARDUINO
HOME AUTOMATION USING ARDUINO
Eklavya Sharma
 

Viewers also liked (11)

Constant Current Regulator for Driving LEDs
Constant Current Regulator for Driving LEDsConstant Current Regulator for Driving LEDs
Constant Current Regulator for Driving LEDs
 
Remote ac power control by android application with lcd display
Remote ac power control by android application with lcd displayRemote ac power control by android application with lcd display
Remote ac power control by android application with lcd display
 
Automatic traffic density monitoring and control system
Automatic traffic density monitoring and control systemAutomatic traffic density monitoring and control system
Automatic traffic density monitoring and control system
 
Final Presentation - Edan&Itzik
Final Presentation - Edan&ItzikFinal Presentation - Edan&Itzik
Final Presentation - Edan&Itzik
 
OpenEnergyMonitor: Univeristy of Turin GreenTo Build Workshop
OpenEnergyMonitor: Univeristy of Turin GreenTo Build WorkshopOpenEnergyMonitor: Univeristy of Turin GreenTo Build Workshop
OpenEnergyMonitor: Univeristy of Turin GreenTo Build Workshop
 
Single phase ac voltage controller
Single phase ac voltage controllerSingle phase ac voltage controller
Single phase ac voltage controller
 
Security system using Arduino
Security system using ArduinoSecurity system using Arduino
Security system using Arduino
 
Thyristors,Commutayion of Thyristor, Power Electronics
Thyristors,Commutayion of Thyristor, Power ElectronicsThyristors,Commutayion of Thyristor, Power Electronics
Thyristors,Commutayion of Thyristor, Power Electronics
 
"Automatic Intelligent Plant Irrigation System using Arduino and GSM board"
"Automatic Intelligent Plant Irrigation System using Arduino and GSM board""Automatic Intelligent Plant Irrigation System using Arduino and GSM board"
"Automatic Intelligent Plant Irrigation System using Arduino and GSM board"
 
Home automation & security system
Home automation & security systemHome automation & security system
Home automation & security system
 
HOME AUTOMATION USING ARDUINO
HOME AUTOMATION USING ARDUINOHOME AUTOMATION USING ARDUINO
HOME AUTOMATION USING ARDUINO
 

Similar to All about ir arduino - cool

Advanced View Arduino Projects List - Use Arduino for Projects 1.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 1.pdfAdvanced View Arduino Projects List - Use Arduino for Projects 1.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 1.pdf
WiseNaeem
 
Arduino Workshop (3).pptx
Arduino Workshop (3).pptxArduino Workshop (3).pptx
Arduino Workshop (3).pptx
HebaEng
 
Arduino: Arduino starter kit
Arduino: Arduino starter kitArduino: Arduino starter kit
Arduino: Arduino starter kit
SANTIAGO PABLO ALBERTO
 
Arduino Slides With Neopixels
Arduino Slides With NeopixelsArduino Slides With Neopixels
Arduino Slides With Neopixels
sdcharle
 
Advanced View Arduino Projects List - Use Arduino for Projects 2.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 2.pdfAdvanced View Arduino Projects List - Use Arduino for Projects 2.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 2.pdf
WiseNaeem
 
NSTA 2013 Denver - ArduBlock and Arduino
NSTA 2013 Denver - ArduBlock and ArduinoNSTA 2013 Denver - ArduBlock and Arduino
NSTA 2013 Denver - ArduBlock and Arduino
Brian Huang
 
Microcontroller Programming & Hardware Introduction
Microcontroller Programming & Hardware IntroductionMicrocontroller Programming & Hardware Introduction
Microcontroller Programming & Hardware Introduction
Joseph Sanchez
 
Advanced View Arduino Projects List - Use Arduino for Projects 5.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 5.pdfAdvanced View Arduino Projects List - Use Arduino for Projects 5.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 5.pdf
WiseNaeem
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digital
Tony Olsson.
 
Advanced View Arduino Projects List - Use Arduino for Projects (4).pdf
Advanced View Arduino Projects List - Use Arduino for Projects (4).pdfAdvanced View Arduino Projects List - Use Arduino for Projects (4).pdf
Advanced View Arduino Projects List - Use Arduino for Projects (4).pdf
Ismailkhan77481
 
Advanced View Arduino Projects List - Use Arduino for Projects-5.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-5.pdfAdvanced View Arduino Projects List - Use Arduino for Projects-5.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-5.pdf
WiseNaeem
 
Lab Manual Arduino UNO Microcontrollar.docx
Lab Manual Arduino UNO Microcontrollar.docxLab Manual Arduino UNO Microcontrollar.docx
Lab Manual Arduino UNO Microcontrollar.docx
RashidFaridChishti
 
Arduino slides
Arduino slidesArduino slides
Arduino slides
sdcharle
 
Arduino Workshop Slides
Arduino Workshop SlidesArduino Workshop Slides
Arduino Workshop Slides
mkarlin14
 
Advanced View Arduino Projects List - Use Arduino for Projects-3.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-3.pdfAdvanced View Arduino Projects List - Use Arduino for Projects-3.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-3.pdf
WiseNaeem
 
ATTiny Light Sculpture Project - Part I (Setup)
ATTiny Light Sculpture Project - Part I (Setup)ATTiny Light Sculpture Project - Part I (Setup)
ATTiny Light Sculpture Project - Part I (Setup)
Brian Huang
 
Embedded system application
Embedded system applicationEmbedded system application
Embedded system application
Dhruwank Vankawala
 
IoT Platform
IoT PlatformIoT Platform
IoT Platform
Saurabh Singh
 
IoT Platform
IoT PlatformIoT Platform
IoT Platform
Saurabh Singh
 
Advanced view arduino projects list use arduino for projects 2
Advanced view arduino projects list  use arduino for projects 2Advanced view arduino projects list  use arduino for projects 2
Advanced view arduino projects list use arduino for projects 2
WiseNaeem
 

Similar to All about ir arduino - cool (20)

Advanced View Arduino Projects List - Use Arduino for Projects 1.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 1.pdfAdvanced View Arduino Projects List - Use Arduino for Projects 1.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 1.pdf
 
Arduino Workshop (3).pptx
Arduino Workshop (3).pptxArduino Workshop (3).pptx
Arduino Workshop (3).pptx
 
Arduino: Arduino starter kit
Arduino: Arduino starter kitArduino: Arduino starter kit
Arduino: Arduino starter kit
 
Arduino Slides With Neopixels
Arduino Slides With NeopixelsArduino Slides With Neopixels
Arduino Slides With Neopixels
 
Advanced View Arduino Projects List - Use Arduino for Projects 2.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 2.pdfAdvanced View Arduino Projects List - Use Arduino for Projects 2.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 2.pdf
 
NSTA 2013 Denver - ArduBlock and Arduino
NSTA 2013 Denver - ArduBlock and ArduinoNSTA 2013 Denver - ArduBlock and Arduino
NSTA 2013 Denver - ArduBlock and Arduino
 
Microcontroller Programming & Hardware Introduction
Microcontroller Programming & Hardware IntroductionMicrocontroller Programming & Hardware Introduction
Microcontroller Programming & Hardware Introduction
 
Advanced View Arduino Projects List - Use Arduino for Projects 5.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 5.pdfAdvanced View Arduino Projects List - Use Arduino for Projects 5.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 5.pdf
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digital
 
Advanced View Arduino Projects List - Use Arduino for Projects (4).pdf
Advanced View Arduino Projects List - Use Arduino for Projects (4).pdfAdvanced View Arduino Projects List - Use Arduino for Projects (4).pdf
Advanced View Arduino Projects List - Use Arduino for Projects (4).pdf
 
Advanced View Arduino Projects List - Use Arduino for Projects-5.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-5.pdfAdvanced View Arduino Projects List - Use Arduino for Projects-5.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-5.pdf
 
Lab Manual Arduino UNO Microcontrollar.docx
Lab Manual Arduino UNO Microcontrollar.docxLab Manual Arduino UNO Microcontrollar.docx
Lab Manual Arduino UNO Microcontrollar.docx
 
Arduino slides
Arduino slidesArduino slides
Arduino slides
 
Arduino Workshop Slides
Arduino Workshop SlidesArduino Workshop Slides
Arduino Workshop Slides
 
Advanced View Arduino Projects List - Use Arduino for Projects-3.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-3.pdfAdvanced View Arduino Projects List - Use Arduino for Projects-3.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-3.pdf
 
ATTiny Light Sculpture Project - Part I (Setup)
ATTiny Light Sculpture Project - Part I (Setup)ATTiny Light Sculpture Project - Part I (Setup)
ATTiny Light Sculpture Project - Part I (Setup)
 
Embedded system application
Embedded system applicationEmbedded system application
Embedded system application
 
IoT Platform
IoT PlatformIoT Platform
IoT Platform
 
IoT Platform
IoT PlatformIoT Platform
IoT Platform
 
Advanced view arduino projects list use arduino for projects 2
Advanced view arduino projects list  use arduino for projects 2Advanced view arduino projects list  use arduino for projects 2
Advanced view arduino projects list use arduino for projects 2
 

Recently uploaded

按照学校原版(Columbia文凭证书)哥伦比亚大学毕业证快速办理
按照学校原版(Columbia文凭证书)哥伦比亚大学毕业证快速办理按照学校原版(Columbia文凭证书)哥伦比亚大学毕业证快速办理
按照学校原版(Columbia文凭证书)哥伦比亚大学毕业证快速办理
uyesp1a
 
一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理
xuqdabu
 
加急办理美国南加州大学毕业证文凭毕业证原版一模一样
加急办理美国南加州大学毕业证文凭毕业证原版一模一样加急办理美国南加州大学毕业证文凭毕业证原版一模一样
加急办理美国南加州大学毕业证文凭毕业证原版一模一样
u0g33km
 
SOLIDWORKS 2024 Enhancements eBook.pdf for beginners
SOLIDWORKS 2024 Enhancements eBook.pdf for beginnersSOLIDWORKS 2024 Enhancements eBook.pdf for beginners
SOLIDWORKS 2024 Enhancements eBook.pdf for beginners
SethiLilu
 
按照学校原版(Greenwich文凭证书)格林威治大学毕业证快速办理
按照学校原版(Greenwich文凭证书)格林威治大学毕业证快速办理按照学校原版(Greenwich文凭证书)格林威治大学毕业证快速办理
按照学校原版(Greenwich文凭证书)格林威治大学毕业证快速办理
yizxn4sx
 
一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证如何办理
一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证如何办理一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证如何办理
一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证如何办理
xuqdabu
 
一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理
nudduv
 
按照学校原版(UVic文凭证书)维多利亚大学毕业证快速办理
按照学校原版(UVic文凭证书)维多利亚大学毕业证快速办理按照学校原版(UVic文凭证书)维多利亚大学毕业证快速办理
按照学校原版(UVic文凭证书)维多利亚大学毕业证快速办理
1jtj7yul
 
按照学校原版(Westminster文凭证书)威斯敏斯特大学毕业证快速办理
按照学校原版(Westminster文凭证书)威斯敏斯特大学毕业证快速办理按照学校原版(Westminster文凭证书)威斯敏斯特大学毕业证快速办理
按照学校原版(Westminster文凭证书)威斯敏斯特大学毕业证快速办理
yizxn4sx
 
按照学校原版(UST文凭证书)圣托马斯大学毕业证快速办理
按照学校原版(UST文凭证书)圣托马斯大学毕业证快速办理按照学校原版(UST文凭证书)圣托马斯大学毕业证快速办理
按照学校原版(UST文凭证书)圣托马斯大学毕业证快速办理
zpc0z12
 
按照学校原版(UOL文凭证书)利物浦大学毕业证快速办理
按照学校原版(UOL文凭证书)利物浦大学毕业证快速办理按照学校原版(UOL文凭证书)利物浦大学毕业证快速办理
按照学校原版(UOL文凭证书)利物浦大学毕业证快速办理
terpt4iu
 
1比1复刻澳洲皇家墨尔本理工大学毕业证本科学位原版一模一样
1比1复刻澳洲皇家墨尔本理工大学毕业证本科学位原版一模一样1比1复刻澳洲皇家墨尔本理工大学毕业证本科学位原版一模一样
1比1复刻澳洲皇家墨尔本理工大学毕业证本科学位原版一模一样
2g3om49r
 
按照学校原版(KCL文凭证书)伦敦国王学院毕业证快速办理
按照学校原版(KCL文凭证书)伦敦国王学院毕业证快速办理按照学校原版(KCL文凭证书)伦敦国王学院毕业证快速办理
按照学校原版(KCL文凭证书)伦敦国王学院毕业证快速办理
terpt4iu
 
一比一原版(ANU文凭证书)澳大利亚国立大学毕业证如何办理
一比一原版(ANU文凭证书)澳大利亚国立大学毕业证如何办理一比一原版(ANU文凭证书)澳大利亚国立大学毕业证如何办理
一比一原版(ANU文凭证书)澳大利亚国立大学毕业证如何办理
nudduv
 
一比一原版(Monash文凭证书)莫纳什大学毕业证如何办理
一比一原版(Monash文凭证书)莫纳什大学毕业证如何办理一比一原版(Monash文凭证书)莫纳什大学毕业证如何办理
一比一原版(Monash文凭证书)莫纳什大学毕业证如何办理
xuqdabu
 
按照学校原版(UAL文凭证书)伦敦艺术大学毕业证快速办理
按照学校原版(UAL文凭证书)伦敦艺术大学毕业证快速办理按照学校原版(UAL文凭证书)伦敦艺术大学毕业证快速办理
按照学校原版(UAL文凭证书)伦敦艺术大学毕业证快速办理
yizxn4sx
 
买(usyd毕业证书)澳洲悉尼大学毕业证研究生文凭证书原版一模一样
买(usyd毕业证书)澳洲悉尼大学毕业证研究生文凭证书原版一模一样买(usyd毕业证书)澳洲悉尼大学毕业证研究生文凭证书原版一模一样
买(usyd毕业证书)澳洲悉尼大学毕业证研究生文凭证书原版一模一样
nvoyobt
 
按照学校原版(UPenn文凭证书)宾夕法尼亚大学毕业证快速办理
按照学校原版(UPenn文凭证书)宾夕法尼亚大学毕业证快速办理按照学校原版(UPenn文凭证书)宾夕法尼亚大学毕业证快速办理
按照学校原版(UPenn文凭证书)宾夕法尼亚大学毕业证快速办理
uwoso
 
Production.pptxd dddddddddddddddddddddddddddddddddd
Production.pptxd ddddddddddddddddddddddddddddddddddProduction.pptxd dddddddddddddddddddddddddddddddddd
Production.pptxd dddddddddddddddddddddddddddddddddd
DanielOliver74
 
按照学校原版(SUT文凭证书)斯威本科技大学毕业证快速办理
按照学校原版(SUT文凭证书)斯威本科技大学毕业证快速办理按照学校原版(SUT文凭证书)斯威本科技大学毕业证快速办理
按照学校原版(SUT文凭证书)斯威本科技大学毕业证快速办理
1jtj7yul
 

Recently uploaded (20)

按照学校原版(Columbia文凭证书)哥伦比亚大学毕业证快速办理
按照学校原版(Columbia文凭证书)哥伦比亚大学毕业证快速办理按照学校原版(Columbia文凭证书)哥伦比亚大学毕业证快速办理
按照学校原版(Columbia文凭证书)哥伦比亚大学毕业证快速办理
 
一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理
 
加急办理美国南加州大学毕业证文凭毕业证原版一模一样
加急办理美国南加州大学毕业证文凭毕业证原版一模一样加急办理美国南加州大学毕业证文凭毕业证原版一模一样
加急办理美国南加州大学毕业证文凭毕业证原版一模一样
 
SOLIDWORKS 2024 Enhancements eBook.pdf for beginners
SOLIDWORKS 2024 Enhancements eBook.pdf for beginnersSOLIDWORKS 2024 Enhancements eBook.pdf for beginners
SOLIDWORKS 2024 Enhancements eBook.pdf for beginners
 
按照学校原版(Greenwich文凭证书)格林威治大学毕业证快速办理
按照学校原版(Greenwich文凭证书)格林威治大学毕业证快速办理按照学校原版(Greenwich文凭证书)格林威治大学毕业证快速办理
按照学校原版(Greenwich文凭证书)格林威治大学毕业证快速办理
 
一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证如何办理
一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证如何办理一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证如何办理
一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证如何办理
 
一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理
 
按照学校原版(UVic文凭证书)维多利亚大学毕业证快速办理
按照学校原版(UVic文凭证书)维多利亚大学毕业证快速办理按照学校原版(UVic文凭证书)维多利亚大学毕业证快速办理
按照学校原版(UVic文凭证书)维多利亚大学毕业证快速办理
 
按照学校原版(Westminster文凭证书)威斯敏斯特大学毕业证快速办理
按照学校原版(Westminster文凭证书)威斯敏斯特大学毕业证快速办理按照学校原版(Westminster文凭证书)威斯敏斯特大学毕业证快速办理
按照学校原版(Westminster文凭证书)威斯敏斯特大学毕业证快速办理
 
按照学校原版(UST文凭证书)圣托马斯大学毕业证快速办理
按照学校原版(UST文凭证书)圣托马斯大学毕业证快速办理按照学校原版(UST文凭证书)圣托马斯大学毕业证快速办理
按照学校原版(UST文凭证书)圣托马斯大学毕业证快速办理
 
按照学校原版(UOL文凭证书)利物浦大学毕业证快速办理
按照学校原版(UOL文凭证书)利物浦大学毕业证快速办理按照学校原版(UOL文凭证书)利物浦大学毕业证快速办理
按照学校原版(UOL文凭证书)利物浦大学毕业证快速办理
 
1比1复刻澳洲皇家墨尔本理工大学毕业证本科学位原版一模一样
1比1复刻澳洲皇家墨尔本理工大学毕业证本科学位原版一模一样1比1复刻澳洲皇家墨尔本理工大学毕业证本科学位原版一模一样
1比1复刻澳洲皇家墨尔本理工大学毕业证本科学位原版一模一样
 
按照学校原版(KCL文凭证书)伦敦国王学院毕业证快速办理
按照学校原版(KCL文凭证书)伦敦国王学院毕业证快速办理按照学校原版(KCL文凭证书)伦敦国王学院毕业证快速办理
按照学校原版(KCL文凭证书)伦敦国王学院毕业证快速办理
 
一比一原版(ANU文凭证书)澳大利亚国立大学毕业证如何办理
一比一原版(ANU文凭证书)澳大利亚国立大学毕业证如何办理一比一原版(ANU文凭证书)澳大利亚国立大学毕业证如何办理
一比一原版(ANU文凭证书)澳大利亚国立大学毕业证如何办理
 
一比一原版(Monash文凭证书)莫纳什大学毕业证如何办理
一比一原版(Monash文凭证书)莫纳什大学毕业证如何办理一比一原版(Monash文凭证书)莫纳什大学毕业证如何办理
一比一原版(Monash文凭证书)莫纳什大学毕业证如何办理
 
按照学校原版(UAL文凭证书)伦敦艺术大学毕业证快速办理
按照学校原版(UAL文凭证书)伦敦艺术大学毕业证快速办理按照学校原版(UAL文凭证书)伦敦艺术大学毕业证快速办理
按照学校原版(UAL文凭证书)伦敦艺术大学毕业证快速办理
 
买(usyd毕业证书)澳洲悉尼大学毕业证研究生文凭证书原版一模一样
买(usyd毕业证书)澳洲悉尼大学毕业证研究生文凭证书原版一模一样买(usyd毕业证书)澳洲悉尼大学毕业证研究生文凭证书原版一模一样
买(usyd毕业证书)澳洲悉尼大学毕业证研究生文凭证书原版一模一样
 
按照学校原版(UPenn文凭证书)宾夕法尼亚大学毕业证快速办理
按照学校原版(UPenn文凭证书)宾夕法尼亚大学毕业证快速办理按照学校原版(UPenn文凭证书)宾夕法尼亚大学毕业证快速办理
按照学校原版(UPenn文凭证书)宾夕法尼亚大学毕业证快速办理
 
Production.pptxd dddddddddddddddddddddddddddddddddd
Production.pptxd ddddddddddddddddddddddddddddddddddProduction.pptxd dddddddddddddddddddddddddddddddddd
Production.pptxd dddddddddddddddddddddddddddddddddd
 
按照学校原版(SUT文凭证书)斯威本科技大学毕业证快速办理
按照学校原版(SUT文凭证书)斯威本科技大学毕业证快速办理按照学校原版(SUT文凭证书)斯威本科技大学毕业证快速办理
按照学校原版(SUT文凭证书)斯威本科技大学毕业证快速办理
 

All about ir arduino - cool

  • 1. Tag Archive | "TSOP4138" Tutorial: Arduino and Infra-red control Posted on 30 March 2011. Tags: 38kHz, arduino, command, control, DFR0094, DFR0107, dfrobot, DIY, duemilanove, education, guide, guides, i2c, infra, infrared, IR, LCD, learn, lesson, lessons, project, receive, red, send, system, tronixstuff, TSOP4138, tutorial, tutorials, uno, Vishay Learn how to use Arduino and infra-red remote controls in chapter thirty-two of a series originally titled “Getting Started/Moving Forward with Arduino!” by John Boxall – A tutorial on the Arduino universe. The first chapter is here, the complete series is detailed here. Updated 10/07/2013 In this article we will look at something different to the usual, and hopefully very interesting and useful – interfacing our Arduino systems with infra-red receivers. Why would we want to do this? To have another method to control our Ardiuno-based systems, using simple infra-red remote controls. A goal of this article is to make things as easy as possible, so we will not look into the base detail of how things work - instead we will examine how to get things done. If you would like a full explanation of infra-red, perhaps see the page on Wikipedia. The remote controls you use for televisions and so on transmit infra-red beam which is turned on and off at a very high speed – usually 38 kHz, to create bits of serial data which are then interpreted by the receiving unit. As the wavelength of infra-red light is too high for human eyes, we cannot see it. However using a digital camera – we can. Here is a demonstration video of IR codes being sent via a particularly fun kit – the adafruit TV-B-Gone: Now to get started. You will need a remote control, and a matching IR receiver device. The hardware and library used in this tutorial only supports NEC, Sony SIRC, Philips RC5, Philips RC6, and raw IR protocols. Or you can purchase a matching set for a good price, such as this example: Or you may already have a spare remote laying around somewhere. I kept this example from my old Sony Trinitron CRT TV after it passed away:
  • 2. It will more than suffice for a test remote. Now for a receiver – if you have purchased the remote/receiver set, you have a nice unit that is ready to be wired into your Arduino, and also a great remote that is compact and easy to carry about. To connect your receiver module – as per the PCB labels, connect Vcc to Arduino 5V, GND to Arduino GND, and D (the data line) to Arduino digital pin 11. Our examples use pin 11, however you can alter that later on. If you are using your own remote control, you will just need a receiver module. These are very cheap, and an ideal unit is the Vishay TSOP4138 (data sheet .pdf). These are available from element-14 and the other usual retail suspects. They are also dead-simple to use. Looking at the following example: From left to right the pins are data, GND and Vcc (to Arduino +5V). So it can be easily wired into a small breadboard for testing purposes. Once you have your remote and receiver module connected, you need to take care of the software side of things. There is a new library to download and install, download it from here. Please note that library doesn’t work for Arduino Leonardo, Freetronics Leostick, etc with ATmega32U4. Instead, use this library (and skip the modification steps below).
  • 3. Extract the IRremote folder and place into the ..arduinoxxxlibraries folder. Then restart your Arduino IDE if it was already open. Using Arduino IDE v1.0 or greater? Open the file “IRRemoteInt.h” in the library folder, and change the line #include "WProgram.h" to #include "Arduino.h" 1 2 3 4 #include "WProgram.h" to #include "Arduino.h" Then save and close the file, restart the Arduino IDE and you’re set. With our first example, we will receive the commands from our remote control and display them on the serial monitor: // example 32.1 - IR receiver code repeater // http://tronixstuff.com/tutorials > chapter 32 // based on code by Ken Shirriff - http://arcfn.com #include <IRremote.h> // use the library int receiver = 11; // pin 1 of IR receiver to Arduino digital pin 11 IRrecv irrecv(receiver); // create instance of 'irrecv' decode_results results; void setup() { Serial.begin(9600); // for serial monitor output irrecv.enableIRIn(); // Start the receiver } void loop() {
  • 4. if (irrecv.decode(&results)) // have we received an IR signal? { Serial.println(results.value, HEX); // display it on serial monitor in hexadecimal irrecv.resume(); // receive the next value } // Your loop can do other things while waiting for an IR command } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 // example 32.1 - IR receiver code repeater // http://tronixstuff.com/tutorials > chapter 32 // based on code by Ken Shirriff - http://arcfn.com #include <IRremote.h> // use the library int receiver = 11; // pin 1 of IR receiver to Arduino digital pin 11 IRrecv irrecv(receiver); // create instance of 'irrecv' decode_results results; void setup() { Serial.begin(9600); // for serial monitor output irrecv.enableIRIn(); // Start the receiver } void loop() { if (irrecv.decode(&results)) // have we received an IR signal? { Serial.println(results.value, HEX); // display it on serial monitor in hexadecimal irrecv.resume(); // receive the next value } // Your loop can do other things while waiting for an IR command } Open the serial monitor box, point your remote control to the receiver and start pressing away. You should see something like this:
  • 5. What have we here? Lots of hexadecimal numbers. Did you notice that each button on your remote control resulted in an individual hexadecimal number? I hope so. The number FFFFFFFF means that the button was held down. The remote used was from a yum-cha discount TV. Now I will try again with the Sony remote: This time, each button press resulted in the same code three times. This is peculiar to Sony IR systems. However nothing to worry about. Looking back at the sketch for example 32.1, the
  • 6. 1 if (irrecv.decode(&results)) section is critical – if a code has been received, the code within the if statement is executed. The hexadecimal code is stored in the variable 1 results.value with which we can treat as any normal hexadecimal number. At this point, press a few buttons on your remote control, and take a note of the matching hexadecimal codes that relate to each button. We will need these codes for the next example… Now we know how to convert the infra-red magic into numbers, we can create sketches to have our Arduino act on particular commands. As the IR library returns hexadecimal numbers, we can use simple decision functions to take action. In the following example, we use switch…case to examine each inbound code, then execute a function. In this case we have an LCD module connected via I2C, and the sketch is programmed to understand fifteen Sony IR codes. If you don’t have an LCD you could always send the output to the serial monitor. If you are using the DFRobot I2C LCD display, you need to use Arduino v23. Furthermore you can substitute your own values if not using Sony remote controls. Finally, this sketch has a short loop after the translateIR(); function call which ignores the following two codes – we do this as Sony remotes send the same code three times. Again. you can remove this if necessary. Note that when using hexadecimal numbers in our sketch we preced them with 0x: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 // example 32.2 - IR receiver code translator // for Sony IR codes (ignores 2nd and 3rd signal repeat) // http://tronixstuff.com/tutorials > chapter 32 // based on code by Ken Shirriff - http://arcfn.com #include "Wire.h" // for I2C bus #include "LiquidCrystal_I2C.h" // for I2C bus LCD module (http://www.dfrobot.com/wiki/index.php/I2C/TWI_LCD1602_Module_(SKU:_DFR0063)) LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display #include <IRremote.h> // use the library for IR int receiver = 11; // pin 1 of IR receiver to Arduino digital pin 11 IRrecv irrecv(receiver); // create instance of 'irrecv' decode_results results; void setup() { lcd.init(); // initialize the lcd lcd.backlight(); // turn on LCD backlight irrecv.enableIRIn(); // Start the receiver } void translateIR() // takes action based on IR code received // describing Sony IR codes on LCD module { switch(results.value) {
  • 7. 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 case 0x37EE: lcd.println(" Favourite "); break; case 0xA90: lcd.println(" Power button "); break; case 0x290: lcd.println(" mute "); break; case 0x10: lcd.println(" one "); break; case 0x810: lcd.println(" two "); break; case 0x410: lcd.println(" three "); break; case 0xC10: lcd.println(" four "); break; case 0x210: lcd.println(" five "); break; case 0xA10: lcd.println(" six "); break; case 0x610: lcd.println(" seven "); break; case 0xE10: lcd.println(" eight "); break; case 0x110: lcd.println(" nine "); break; case 0x910: lcd.println(" zero "); break; case 0x490: lcd.println(" volume up "); break; case 0xC90: lcd.println(" volume down "); break; case 0x90: lcd.println(" channel up "); break; case 0x890: lcd.println(" channel down "); break; default: lcd.println(" other button "); } delay(500); lcd.clear(); } void loop() { if (irrecv.decode(&results)) // have we received an IR signal? { translateIR(); for (int z=0; z<2; z++) // ignore 2nd and 3rd signal repeat { irrecv.resume(); // receive the next value } } } And here it is in action: You might be thinking “why would I want to make things appear on the LCD like that?”. The purpose of the example is to show how to react to various IR commands. You can replace the LCD display functions with other functions of your choosing. At the start working with infra-red may have seemed to be complex, but with the previous two examples it should be quite simple by now. So there you have it, another useful way to control our Arduino systems. Hopefully you have some ideas on how to make use of this technology. In future articles we will examine creating and sending IR codes from our Arduino. Furthermore, a big thanks to Ken Shirriff for his Arduino library. Have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, subscribe for email updates or RSS using the links on the right-hand column, or join our Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other – and we can all learn something.
  • 8. Arduino Tutorials Click for Detailed Chapter Index Chapters 0 1 2 3 4 Chapters 5 6 6a 7 8 Chapters 9 10 11 12 13 Ch. 14 - XBee Ch. 15 - RFID - RDM-630 Ch. 15a - RFID - ID-20 Ch. 16 - Ethernet Ch. 17 - GPS - EM406A Ch. 18 - RGB matrix - awaiting update Ch. 19 - GPS - MediaTek 3329 Ch. 20 - I2C bus part I Ch. 21 - I2C bus part II Ch. 22 - AREF pin Ch. 23 - Touch screen Ch. 24 - Monochrome LCD Ch. 25 - Analog buttons Ch. 26 - GSM - SM5100 Uno Ch. 27 - GSM - SM5100 Mega Ch. 28 - Colour LCD Ch. 29 - TFT LCD touch screen Ch. 30 - Arduino + twitter Ch. 31 - Inbuilt EEPROM Ch. 32 - Infra-red control Ch. 33 - Control AC via SMS Ch. 34 - SPI bus part I Ch. 35 - Video-out Ch. 36 - SPI bus part II Ch. 37 - Timing with millis() Ch. 38 - Thermal Printer Ch. 39 - NXP SAA1064 Ch. 40 - Push wheel switches Ch. 40a - Wheel switches II Ch. 41 - More digital I/O Ch. 42 - Numeric keypads Ch. 43 - Port Manipulation - Uno Ch. 44 - ATtiny+Arduino Ch. 45 - Ultrasonic Sensor Ch. 46 - Analog + buttons II Ch. 47 - Internet-controlled relays Ch. 48 - MSGEQ7 Spectrum Analyzer First look - Arduino Due Ch. 49 - KTM-S1201 LCD modules Ch. 50 - ILI9325 colour TFT LCD modules Ch. 51 - MC14489 LED display driver IC Ch. 52 - NXP PCF8591 ADC/DAC IC Ch. 53 - TI ADS1110 16-bit ADC IC Ch. 54 - NXP PCF8563 RTC
  • 9. Ch. 55 - GSM - SIM900 Ch. 56 - MAX7219 LED driver IC Ch. 57 - TI TLC5940 LED driver IC Ch. 58 - Serial PCF8574 LCD Backpacks Arduino Yún tutorials pcDuino tutorials The Arduino Book Interesting Sites David L. Jones' eev blog Freetronics Arduino Geniuses! Silicon Chip magazine Always a great read! Talking Electronics Amazing Arduino Shield Directory Dangerous Prototypes The Amp Hour podcast EEWeb Elec Engineering Forum Superhouse.tv High-tech home renovation Mr Dick Smith OA .