How-to · Beginner · 3 min read
IR Remote Receivers
VS1838B, TSOP and How to Decode a Remote With Arduino
By Geekobot Learning Team · Updated 29 Oct 2026
On this page
An IR receiver such as the VS1838B contains a photodiode and a filter tuned to 38 kHz. It outputs the on/off pattern of a remote control on one pin. Connect it to power, ground and a digital input, install the IRremote library and print the codes of each button. To send IR, use a 940 nm LED driven by a transistor.
Key specs at a glance
- Carrier
- 38 kHz (VS1838B, TSOP38238 and similar)
- Supply
- 2.7 to 5.5 V on most; check the module
- Output
- Digital, normally high, pulled low during a burst
- Range
- Up to about 8 to 10 m for a standard remote
- Protocols
- NEC, Sony SIRC, RC5, Samsung and others
- Pins
- OUT, GND, VCC; order depends on the part, check the data sheet
How an IR remote works
A remote flashes an infrared LED in a coded pattern at 38 kHz. The receiver ignores sunlight and lamps and outputs the demodulated pulse train. The NEC protocol, used by many cheap remotes, sends a start burst (9 ms on, 4.5 ms off) followed by 32 bits: address, inverted address, command and inverted command. Libraries turn the timings into the address and command numbers.
Wiring
Connect VCC to 3.3 V or 5 V, GND to ground and OUT to a digital pin (pin 2 or 11 on an Uno). The VS1838B has three pins: with the dome facing you, check the data sheet for the exact order, because breakout boards differ. A 100 nF capacitor across the supply and a 100 Ω series resistor help in noisy circuits.
Decoding button codes
Install the IRremote library, upload this sketch and open the Serial Monitor. Press each button and write down the command number.
#include <IRremote.hpp>
const uint8_t IR_PIN = 2;
void setup() {
Serial.begin(115200);
IrReceiver.begin(IR_PIN, ENABLE_LED_FEEDBACK);
}
void loop() {
if (IrReceiver.decode()) {
Serial.print("Protocol: ");
Serial.print(getProtocolString(IrReceiver.decodedIRData.protocol));
Serial.print(" Command: 0x");
Serial.println(IrReceiver.decodedIRData.command, HEX);
IrReceiver.resume(); // ready for the next code
}
}Sending IR codes
Use a 940 nm IR LED with a transistor (for example a 2N2222 or an N-channel MOSFET) because a microcontroller pin cannot drive enough current for good range. Use the library's send functions to repeat the codes you captured. An IR transmitter module with a built-in driver is easier. See transistors.
Troubleshooting
check the pinout and that the receiver is 38 kHz, and that the remote battery is good.
sunlight, fluorescent or dimmer noise; add a capacitor or shield the receiver.
weak battery in the remote or a 36 kHz/56 kHz remote on a 38 kHz receiver.
use a phone camera to see if the IR LED flashes; add a transistor.
Try it: Led resistor calculator
Change the values and the diagram and results update as you type.
Common mistakes to avoid
- Mixing up the pin order on the receiver.
- Driving the IR LED straight from the pin and expecting range.
- Using a 56 kHz remote with a 38 kHz receiver.
- Forgetting to call resume() after each decode.
- Leaving the receiver in direct sunlight.
Frequently asked questions
Can I use any IR LED?
Use 940 nm LEDs, which match the receiver. Visible red LEDs will not work.
What is the difference between VS1838B and TSOP38238?
Both are 38 kHz receivers. The TSOP is more noise tolerant and consistent, the VS1838B is cheaper.
Can I use one receiver with many remotes?
Yes, if they use 38 kHz. The library decodes common protocols.
How do I find my TV remote codes?
Capture each button with the sketch above and record the protocol and command.
Does it work on 3.3 V boards?
Yes, most receivers run from 2.7 V up.
Parts for this guide
Calculators
Terms in this guide
Projects that use it
Put this into practice: 7 step-by-step builds in our project library use parts from this guide.
Keep learning
Sources
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.




