Projects / Remote control code reader

Remote control code reader

Beginner1.5 hGuided buildReviewed

Build it step by step

0 of 8 done
  1. NANOVS1838B

    Wire the receiver

    OUT to D11, GND to GND, VCC to 5V.

  2. NANO

    Upload the sketch

    Serial monitor shows a ready message.

  3. NANO

    Press a button on a remote

    The protocol, address and command print.

  4. NANO

    Press the same button again

    The same command appears.

  5. NANO

    Hold a button down

    Repeat codes are ignored.

  6. NANO

    Write the codes of five buttons

    Make a table.

  7. NANO

    Try a second remote

    Compare protocols.

  8. NANO

    Point it away

    Distance and angle affect reception.

In short

How do you build a remote control code reader?

An IR receiver reads the codes from any remote and prints them so you can use them in your own projects. You need Arduino Nano, IR receiver VS1838B, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm). It takes 8 steps and about 90 minutes.

Level
Beginner
Time
About 90 min
Parts
4

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
VS1838B pin 1 (OUT)Nano D11Demodulated signal, dome facing you, pin 1 on the left
VS1838B pin 2 (GND)Nano GNDGround
VS1838B pin 3 (VCC)Nano 5VPower

Code

Most remotes send a short burst of infrared light flashing on and off at about 38 kilohertz, with the pattern of gaps carrying the code. The VS1838B receiver filters out that carrier and ambient light and outputs a clean pulse train, which the IRremote library measures with a timer and decodes into a protocol name, an address and a command number. NEC is the commonest protocol, used by many cheap remotes; Sony and Samsung are also supported. A held button sends short repeat codes, which the sketch ignores so each press prints once. Write down the command numbers of the buttons you want and use them in your own sketch with an if or switch statement to control lamps, motors or menus. If a remote shows as unknown, it may use a rarer protocol; the raw timing printout lets you compare patterns. A phone camera shows the remote's infrared light as a faint purple flicker, which is a quick way to check the remote's battery. Sunlight and some energy-saving lamps can interfere with reception.

Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

#include <IRremote.hpp>

const int IR_PIN = 11;

void setup() {
  Serial.begin(9600);
  IrReceiver.begin(IR_PIN, ENABLE_LED_FEEDBACK);     // the on-board LED blinks on each code
  Serial.println("Point a remote at the receiver and press a button");
}

void loop() {
  if (IrReceiver.decode()) {
    if (IrReceiver.decodedIRData.protocol == UNKNOWN) {
      Serial.println("Unknown protocol, raw data:");
      IrReceiver.printIRResultRawFormatted(&Serial, true);
    } else if (!(IrReceiver.decodedIRData.flags & IRDATA_FLAGS_IS_REPEAT)) {
      Serial.print("Protocol ");
      Serial.print(getProtocolString(IrReceiver.decodedIRData.protocol));
      Serial.print("  address 0x");
      Serial.print(IrReceiver.decodedIRData.address, HEX);
      Serial.print("  command 0x");
      Serial.println(IrReceiver.decodedIRData.command, HEX);
    }
    IrReceiver.resume();                              // get ready for the next code
  }
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Press power on a TV remoteA command code prints
Same button againSame code
Another buttonDifferent code
Hold a buttonOne line only
Aim away from the sensorNothing prints

If it does not work

Nothing prints

Check pin order, the dome faces you and OUT is on the left.

Always unknown

Try another remote or move closer.

Codes change each press

Some remotes use a rolling code, use another.

Compile error on IrReceiver

Install IRremote version 4 or later.

Noisy prints

Bright lamps nearby can interfere, shade the receiver.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the remote control code reader?

Arduino Nano, IR receiver VS1838B, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm).

How long does the remote control code reader take to build?

About 90 minutes for a beginner maker, in 8 steps.

How do I know the remote control code reader works?

Press power on a TV remote: A command code prints. Same button again: Same code. Another button: Different code.

Nothing prints: what should I check?

Check pin order, the dome faces you and OUT is on the left.

Always unknown: what should I check?

Try another remote or move closer.

Codes change each press: what should I check?

Some remotes use a rolling code, use another.

Compile error on IrReceiver: what should I check?

Install IRremote version 4 or later.