<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

Infrared Remote Control receiver with repeat key handling - Arduino

Return to chapter overview


IR remote control is very easy to implement with a cheap IR receiver module. It will work with almost any old remote control that you have lying around - don't throw them away! Instead of just using a bare Infrared photodiode, buy a module that contains the photodiode, preamplifier and carrier wave filters in the same package, like the Vishay TSOP4838 which works on both 3.3V and 5V controllers. There is a very nice Arduino IRremote library which has the code to handle almost all remote controller models.

But the IRremote library doesn't handle "repeat keys" very well - or keys which should not repeat. Here you'll find some simple wrapper code which will do this for you.

IR remote controls work on different carrier frequencies, so it's important to use an IR receiver module that works at the right frequency. Modules are available for 30kHz, 33kHz, 36kHz, 38kHz, 40kHz and 56kHz. You can usually find the frequency of your remote control from an internet search. 38kHz is the most common. Each manufacturer and product uses a different encoding, so the receivers [usually] don't get confused. Manufacturers say that the more recent (e.g. more expensive) IR receiver modules are better at handling interference from lights etc, but I found that the really cheap ones work very well in a normal room situation (unless you are doing arc welding).


Vishay IR Receiver Modules are good, for example:

Protosupplies always has good descriptions of common modules (and they sell the IR module for less than $1, if you live in the USA):

Also check out the Infrared Controller Knowledge Base (PDF), everything you need to know, and more, about IR remotes.


This is the typical IR receiver module, with an onboard 'key pressed' LED and a power supply smoothing circuit. VCC can be 3.3 or 5V - use the same VCC as your microcontroller. 'Signal' connects to any digital input, define this input in the code.



How do you find the carrier frequency of an IR remote control?

Before you buy the IR receiver, you need to find out what carrier frequency you need for the IR remote control you want to use. If you have an infrared phototransistor (e.g. a QSD123 or 124) and an oscilloscope, then it's easy. Wire up the phototransistor as shown below, and view the waveform it receives when you press a button on the remote. The carrier wave is only visible when the IR signal is pulled low. Measure the time between the peaks of the carrier wave - that gives you the frequency. If your fancy 'scope has an FFT feature, you can use that to get the frequency. If you don't have a 'scope, another solution is to buy receivers for all the frequencies (30, 33, 36, 38, 40 and 56kHz), and see which one works best.






Using an Analog Discovery 2 with the FFT feature it's very easy...


This is the 'Signal' output when viewed on the oscilloscope, with the carrier wave filtered out. This waveform is decoded by the IR library.




The example sketch outputs remote key depressions to the Serial Monitor, or PuTTY etc. The code has been tested on a Zero and an UnoR3.

  Arduino Source Code, IrRemote1.h   [Click to expand]

  Arduino Source Code, example sketch, IrRemote1.ino   [Click to expand]

  Download IRremote1.zip


Pretty pictures

You can use any old remote you have lying around - never throw them away! An old Christmas tree lights controller works quite well. And check under the sofa too.