Preview build — page text is a draft awaiting human review. Code badges come from real compiles. The flasher is real but not yet hardware-tested; the Playground is still a preview.

VS1838B IR receiver with Arduino Nano — decode any TV remote

Wire a VS1838B IR receiver to an Arduino Nano on D2, decode NEC and other remotes with IRremote 4.x, and know which pins and timers it takes.

Arduino C++Verified — core avr 1.8.8, IRremote 4.7.1, 3 Nov 2026Compile-only

Community draft — report a mistake

A ₹20 IR receiver turns any old TV remote into a wireless keypad for the Nano. The receiver’s OUT pin goes to D2; it is powered from 5V like everything else on the Nano.

Press keys and note the command codes; then use them in a switch to toggle relays or LEDs. The on-board LED flickers on every frame received, which makes wiring problems easy to spot.

Wiring

Arduino NanoOnly the pins used are shown · 5 V logicVS1838B IR receiver (38 kHz)5VGNDD2OUTGNDVCC
Every connection
Arduino NanoVS1838B IR receiver (38 kHz)WireNotes
D2OUTyellow
GNDGNDblack
5VVCCred

2.7–5.5 V part, 5 V board. Power it from your board's logic voltage; OUT is an active-LOW signal at VCC level.

Board quirks

  • Bare VS1838B pin order, looking at the dome: OUT, GND, VCC. Module boards often reorder them — follow the print.
  • IRremote uses Timer2 on the Nano, so tone() and analogWrite() on D3 and D11 stop working. Servo (Timer1) and millis() (Timer0) are unaffected.
  • Most Indian set-top box and TV remotes use the NEC protocol; AC remotes send long frames that IRremote shows as “UNKNOWN” or as several packets.
  • Sunlight and CFL/LED tube lights add noise. Shade the dome and add a 100 nF capacitor across VCC/GND close to the receiver.

Code

ir-receiver-nano.inoArduino C++Open in PlaygroundOpen in PlaygroundFlash
// VS1838B IR receiver on an Arduino Nano: prints protocol, address and command of any remote.
// OUT → D2, GND → GND, VCC → 5V. IRremote uses Timer2 on the ATmega328P, so tone() and
// analogWrite() on D3/D11 stop working while it runs.
#include <IRremote.hpp>

const uint8_t IR_PIN = 2;

void setup() {
  Serial.begin(115200);
  IrReceiver.begin(IR_PIN, ENABLE_LED_FEEDBACK);  // the on-board LED flickers on each frame
  Serial.println(F("Point a remote at the receiver and press a key"));
}

void loop() {
  if (IrReceiver.decode()) {
    if (IrReceiver.decodedIRData.flags & IRDATA_FLAGS_IS_REPEAT) {
      Serial.println(F("(repeat)"));
    } else {
      Serial.print(F("Protocol: "));
      Serial.print(getProtocolString(IrReceiver.decodedIRData.protocol));
      Serial.print(F("  Address: 0x"));
      Serial.print(IrReceiver.decodedIRData.address, HEX);
      Serial.print(F("  Command: 0x"));
      Serial.println(IrReceiver.decodedIRData.command, HEX);
    }
    IrReceiver.resume();
  }
}

Library: IRremote (Armin Joachimsmeyer (shirriff, z3t0)) — compiled with IRremote 4.7.1.

Expected serial output

Serial Monitor · 115200Output
Point a remote at the receiver and press a key
Protocol: NEC  Address: 0x0  Command: 0x45
(repeat)
Protocol: NEC  Address: 0x0  Command: 0x46

Common errors

IRremote.h: old example code does not compile

IRremote 4.x replaced irrecv.decode(&results) with IrReceiver.decode() and IrReceiver.decodedIRData. Use the sketch on this page.

Nothing is printed

Wrong pin order (the bare part gets hot if VCC/GND are swapped) or a 56 kHz remote. Check with a phone camera that the remote LED flashes.

↑↓ to move · Enter to open