IR Remote Arduino Demo


Universal Remote (#020-00001) and IR Receiver (#350-00014)

An infrared receiver connected to your microcontroller project can receive coded signals from a universal remote control, at line-of-sight distances of up to about 12 feet. 

The Universal Remote emits a different infrared light signal with each button pressed. The infrared detector receives these coded signals, and turns them into a series of pulses. Programming running in the microcontroller reads the sequence of these pulses, and determines which button has been pressed on the remote control.

This tutorial connects the IR Receiver to the Board of Education Shield, and displays codes received from the Universal Remote with the Arduino software's Serial Monitor. 





To connect the IR remote detector to the Arduino Shield, attach the three leads of the device as shown in the figure.

Be sure not to reverse the 5 V power and ground connections of the infrared detector, or damage to the device may occur.


Prepare the Remote

The remote control may be pre-programmed to communicate with various brands of consumer electronic equipment. For this demonstration, the remote is programmed so that it uses the code settings for a Sony TV.

Follow the instructions packaged with the remote control to program it for Sony protocol; code 605. In general:

  1. Press Setup until red LED on top stays on
  2. Enter code 605


Arduino Programming


Download Arduino Demo Code


To use this example, upload the demo sketch to your Arduino, then open the Serial Monitor window. Ensure that the Baud Rate is set at 9600.

Hold the remote control a few feet away from the IR detector, and press a number button on the remote. The coded value of that button is shown in the Serial Monitor window. The following table shows the code values returned when pressing the buttons on the remote control.  Code values are displayed in hexadecimal format, 000 to FFF. They are shown this way to help avoid typing errors when coding your sketches. For example, code A90 is equivalent to decimal 2704.

ButtonCode Value
Channel Up90
Channel Down890
Volume Up490
Volume DownC90
Previous ChannelDD0


This sketch requires the use of a third-party library, IRRemote. It is included in the download with the example sketch. To use this library, if it’s running exit the Arduino IDE software, and move IRRemote folder to your Arduino sketchbook libraries folder. This is typically in (My) Documents\Arduino\libraries. Restart the IDE software, then load and run the sketch.

// Program remote:
//   Press Setup until red LED on top stays on
//   Enter code 605

#include <IRremote.h>        // Must be located in sketchbook
                    //  libraries folder

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup() {
  irrecv.enableIRIn();        // Start the receiver

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume();          // Receive the next value