The VS1838B is a three-legged IR receiver that picks up the 38 kHz signal from almost any TV, AC or DTH remote. With the IRremote library, an Uno can turn every spare remote in the house into a controller for lights, fans or a robot.
On the Uno it runs from 5V and its output goes to D2. The point to know before you build: IRremote takes over Timer2, so D3 and D11 lose PWM and tone() stops working while the receiver is active. Plan the rest of your pins around that.
The sketch prints the protocol, address and command for every button you press. Note the codes down, then react to them in your own project.
Wiring
| Arduino Uno R3 | VS1838B IR receiver (38 kHz) | Wire | Notes |
|---|---|---|---|
| D2 | OUT | yellow | Any digital pin works; IRremote samples it on a timer. |
| GND | GND | black | |
| 5V | VCC | red | Bare receiver, dome facing you: OUT, GND, VCC from left. Modules on a small PCB print their own order (often S, −, +) — follow the print. |
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
- IRremote uses the Uno’s Timer2. While it runs,
analogWrite()on D3 and D11 and thetone()function stop working — use D5, D6, D9 or D10 for PWM. - Write down each button’s Command code, then use it in an
iforswitchto drive LEDs or relays. - Holding a button sends a short repeat frame, not the code again (on NEC remotes). The sketch prints “(repeat)” for those.
- Air-conditioner remotes send long frames with the whole state (temperature, mode, fan). IRremote shows them as a protocol with a long raw value; it can’t decode every AC brand.
Code
// VS1838B IR receiver on an Arduino Uno R3 with IRremote 4.x.
// OUT → D2, GND → GND, VCC → 5V. Point any TV/AC/set-top-box remote at it and
// press buttons: the protocol, address and command code are printed.
#include <IRremote.hpp>
const uint8_t IR_PIN = 2;
void setup() {
Serial.begin(9600);
IrReceiver.begin(IR_PIN, ENABLE_LED_FEEDBACK); // the "L" LED blinks on every signal
Serial.println(F("IR receiver on D2 - press a remote button"));
}
void loop() {
if (!IrReceiver.decode()) return;
IRData &d = IrReceiver.decodedIRData;
if (d.flags & IRDATA_FLAGS_IS_REPEAT) {
Serial.println(F("(repeat)"));
} else {
Serial.print(F("Protocol "));
Serial.print(getProtocolString(d.protocol));
Serial.print(F(" Address 0x"));
Serial.print(d.address, HEX);
Serial.print(F(" Command 0x"));
Serial.println(d.command, HEX);
if (d.protocol == UNKNOWN) Serial.println(F("Unknown protocol - try another button or remote"));
}
IrReceiver.resume(); // ready for the next code
}// VS1838B IR receiver on an Arduino Uno R3 with IRremote 4.x.
// OUT → D2, GND → GND, VCC → 5V. Point any TV/AC/set-top-box remote at it and
// press buttons: the protocol, address and command code are printed.
#include <IRremote.hpp>
const uint8_t IR_PIN = 2;
void setup() {
Serial.begin(9600);
IrReceiver.begin(IR_PIN, ENABLE_LED_FEEDBACK); // the "L" LED blinks on every signal
Serial.println(F("IR receiver on D2 - press a remote button"));
}
void loop() {
if (!IrReceiver.decode()) return;
IRData &d = IrReceiver.decodedIRData;
if (d.flags & IRDATA_FLAGS_IS_REPEAT) {
Serial.println(F("(repeat)"));
} else {
Serial.print(F("Protocol "));
Serial.print(getProtocolString(d.protocol));
Serial.print(F(" Address 0x"));
Serial.print(d.address, HEX);
Serial.print(F(" Command 0x"));
Serial.println(d.command, HEX);
if (d.protocol == UNKNOWN) Serial.println(F("Unknown protocol - try another button or remote"));
}
IrReceiver.resume(); // ready for the next code
}Library: IRremote (Armin Joachimsmeyer (shirriff, z3t0)) — compiled with IRremote 4.7.1.
Expected serial output
IR receiver on D2 - press a remote button
Protocol NEC Address 0x0 Command 0x45
(repeat)
Protocol NEC Address 0x0 Command 0x46IR receiver on D2 - press a remote button Protocol NEC Address 0x0 Command 0x45 (repeat) Protocol NEC Address 0x0 Command 0x46
Common errors
Nothing prints, but the L LED blinks
Signals arrive but don’t decode. Check the remote’s battery and try another button. Also make sure no other library uses Timer2.
The receiver gets hot or the Uno resets
VCC and GND are reversed — common with bare receivers. Unplug at once and check the pin order (OUT, GND, VCC, dome facing you).
“IRremote.h” compile errors or old <code>IRrecv</code> examples fail
IRremote 4.x replaced the old API. Use #include <IRremote.hpp> and IrReceiver, as in this sketch.