0% found this document useful (0 votes)
671 views4 pages

IRremote Library, Send & Receive Infrared Remote Control

The IRremote library allows a microcontroller like a Teensy to receive and transmit infrared remote control codes. It acts like two libraries - one for receiving codes using an IR receiver module, and one for transmitting codes using an IR LED. Example code is provided to demonstrate receiving codes and printing the protocol and value, and transmitting codes using NEC format. The library requires a timer but can be configured to use an alternative timer if needed. More documentation is available on the original author's website.

Uploaded by

Jayant Swami
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
671 views4 pages

IRremote Library, Send & Receive Infrared Remote Control

The IRremote library allows a microcontroller like a Teensy to receive and transmit infrared remote control codes. It acts like two libraries - one for receiving codes using an IR receiver module, and one for transmitting codes using an IR LED. Example code is provided to demonstrate receiving codes and printing the protocol and value, and transmitting codes using NEC format. The library requires a timer but can be configured to use an alternative timer if needed. More documentation is available on the original author's website.

Uploaded by

Jayant Swami
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

5/2/12

IRremote Library, Send & Receive Infrared Remote Control

Shopping Cart

Checkout

Shipping Cost

Download Website

Home

MP3 Player
Teensyduino

8051 Tools
Libraries IRremote

All Projects

PJRC Store

Site Map
Search PJRC

You are here: Teensy

PJRC Store
Teensy, $16 Teensy Pins, $19 Teensy++, $24 Teensy++ Pins, $27 USB Cable, $4

IRremote Library
IRremote, by Ken Shirriff, allows you to receive or transmit Infrared Remote Control codes. You can make your projects controlled by a remote, or make them control other devices like televisions and stereo components. Download: IRremote.zip (modified to work on Teensy and other boards)

Teensy
Main Page Getting Started How-To Tips Code Library Projects Teensyduino Main Tutorial Download+Install Basic Usage Digital I/O Timing USB Serial USB Keyboard USB Mouse USB Joystick USB MIDI USB Flight Sim UART Serial Libraries Main List GLCD LiquidCrystal Matrix/Sprite LedDisplay LedControl DogLcd ST7565 AltSoftSerial NewSoftSerial SoftwareSerial MIDI PS2Keyboard DmxSimple Firmata Wire SPI OneWire XBee VirtualWire X10 IRremote TinyGPS USBHostShield Ethernet Bounce Keypad Encoder

Hardware Requirements
For transmitting, a single Infrared LED and resistor are needed. For receiving, an IR receiver module with internal bandpass filter is needed.

For transmitting, you must connect the LED to a specific pin. The receiver output may be connected to any pin. Board Teensy 1.0 Teensy 2.0 Teensy++ 1.0 Teensy++ 2.0 Receive Transmit Timer PWM Pins Pin Pin Used Disabled Any Any Any Any 17 10 1 1 1 4 2 2 15, 18 12 0 0

www.pjrc.com/teensy/td_libs_IRremote.html

1/4

5/2/12

IRremote Library, Send & Receive Infrared Remote Control

Ping CapSense FreqCount FreqMeasure Servo Stepper AccelStepper FrequencyTimer2 Tlc5940 SoftPWM ShiftPWM DateTime Metro TimerOne MsTimer2 EEPROM Reference

Basic Usage
IRremote acts like 2 libraries, one for sending and one for receiving. Usually it's easiest to find the codes to transmit by first using the receiver.

Receiving
IRrecv irrecv(receivePin)
Create the receiver object, using a name of your choice.

irrecv.enableIRIn()
Begin the receiving process. This will enable the timer interrupt which consumes a small amount of CPU every 50 s.

irrecv.decode(&results)
Attempt to receive a IR code. Returns true if a code was received, or false if nothing received yet. When a code is received, information is stored into "results". results.decode_type: Will be one of the following: NEC, SONY, RC5, RC6, or UNKNOWN. results.value: The actual IR code (0 if type is UNKNOWN) results.bits: The number of bits used by this code results.rawbuf: An array of IR pulse times results.rawlen: The number of items stored in the array

irrecv.resume()
After receiving, this must be called to reset the receiver and prepare it to receive another code.

irrecv.blink13(true)
Enable blinking the LED when during reception. Because you can't see infrared light, blinking the LED can be useful while troubleshooting, or just to give visual feedback.

Transmitting
IRsend irsend;
Create the transmit object. A fixed pin number is always used, depending on which timer the library is utilizing.

irsend.sendNEC(IRcode, numBits);
Send a code in NEC format.

irsend.sendSony(IRcode, numBits);
Send a code in Sony format.

irsend.sendRC5(IRcode, numBits);
Send a code in RC5 format.

irsend.sendRC6(IRcode, numBits);
Send a code in RC6

irsend.sendRaw(rawbuf, rawlen, frequency);


Send a raw code. Normally you would obtain the contents of rawbuf and rawlen by using the receiver many times and averaging the results. Some adjustments may be necessary for best performance. The frequency is the expected bandpass filter frequency at the receiver, where 38 is the most commonly used.

Example Program - Receive

www.pjrc.com/teensy/td_libs_IRremote.html

2/4

5/2/12

IRremote Library, Send & Receive Infrared Remote Control

#nld <Reoeh icue Irmt.> cntitRC_I =6 os n EVPN ; Irc irc(EVPN; Rev revRC_I) dcd_eut rsls eoersls eut; vi stp) od eu( { Sra.ei(60; eilbgn90) irc.nbeRn) / Sattercie revealII(; / tr h eevr irc.ln1(re; revbik3tu) } vi lo( { od op) i (revdcd(rsls){ f irc.eoe&eut) i (eut.eoetp = NC { f rslsdcd_ye = E) Sra.rn(NC "; eilpit"E: ) }es i (eut.eoetp = SN){ le f rslsdcd_ye = OY Sra.rn(SN:"; eilpit"OY ) }es i (eut.eoetp = R5 { le f rslsdcd_ye = C) Sra.rn(R5 "; eilpit"C: ) }es i (eut.eoetp = R6 { le f rslsdcd_ye = C) Sra.rn(R6 "; eilpit"C: ) }es i (eut.eoetp = UKON { le f rslsdcd_ye = NNW) Sra.rn(UKON "; eilpit"NNW: ) } Sra.rnl(eut.au,HX; eilpitnrslsvle E) irc.eue) / Rcietenx vle revrsm(; / eev h et au } }

Example Program - Transmit


#nld <Reoeh icue Irmt.> Isn isn; Red red vi stp){ od eu( } vi lo( { od op) isn.edoy06B2 2) redsnSn(x89, 0; dly10; ea(0) isn.edoy06B2 2) redsnSn(x89, 0; dly10; ea(0) isn.edoy06B2 2) redsnSn(x89, 0; dly300) ea(000; }

www.pjrc.com/teensy/td_libs_IRremote.html

3/4

5/2/12

IRremote Library, Send & Receive Infrared Remote Control

Timer Usage
IRremote requires a timer for both transmitting and receiving. If you wish to use another library that requires the same timer, you can edit IRremoteInt.h to make IRremote use a different timer.

Details
For more details, please refer to Ken's pages: A Multi-Protocol Infrared Remote Library for the Arduino Understanding Sony IR remote codes, LIRC files, and the Arduino library Detecting an IR Beam Break with the Arduino IR Library Don't walk! Controlling a pedestrian sign with an Arduino Using arbitrary remotes with the Arduino IRremote library Controlling your stereo over the web with the Arduino infrared library IR Bubbles: Controlling a relay with an Arduino and an IR remote An Arduino universal remote: record and playback IR signals

www.pjrc.com/teensy/td_libs_IRremote.html

4/4

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy