Build it step by step
0 of 4 doneCheck the pinout
With the dome facing you, VS1838B pins are OUT, GND, VCC from left to right. Some modules differ: check the print.
Wire it
OUT to D2, GND, VCC to 5V. Add the three LEDs on D9, D10, D11.
Read your remote
Upload, open the serial monitor and press buttons. Note the Command value of three buttons.
Map buttons
Put those three numbers in KEYS, upload again, and use the buttons to toggle the LEDs.
How do you build a TV remote code reader?
Point any TV or AC remote at a VS1838B receiver and the serial monitor prints its protocol, address and command for each button. You need Arduino Uno R3, IR receiver VS1838B, LED 5 mm red, LED 5 mm green, LED 5 mm yellow, Resistor 220 Ω × 3, Breadboard 400 points (half size) and Jumper wires male to male (40 pcs, 20 cm). It takes 4 steps and about 35 minutes.
- Level
- Beginner
- Time
- About 35 min
- Parts
- 8
Parts list
- Development BoardsBuyArduino Uno R3 × 1
- SensorsBuy
- SemiconductorsBuyLED 5 mm red × 1
- SemiconductorsBuyLED 5 mm green × 1
- SemiconductorsBuyLED 5 mm yellow × 1
- PassivesBuyResistor 220 Ω × 3
- PrototypingBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| VS1838B OUT (left pin, facing the dome) | Uno D2 | Demodulated signal |
| VS1838B GND (middle) | Uno GND | Ground |
| VS1838B VCC (right) | Uno 5V | Power |
| Uno D9 / D10 / D11 | 220 Ω, red / green / yellow LED, GND | Lights for three buttons |
Code
Arduino IDE, board "Arduino Uno". Install "IRremote" (version 4 or newer) by shirriff, z3t0 and ArminJo.
Runs on a virtual Arduino Uno 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 LEDS[3] = {9, 10, 11};
// After reading your remote, put the command numbers of three buttons here:
const uint8_t KEYS[3] = {0x0C, 0x18, 0x5E};
void setup() {
Serial.begin(9600);
for (int p : LEDS) pinMode(p, OUTPUT);
IrReceiver.begin(2, ENABLE_LED_FEEDBACK); // the Uno's built-in LED flashes on each signal
Serial.println("Press buttons on any remote");
}
void loop() {
if (!IrReceiver.decode()) return;
IrReceiver.printIRResultShort(&Serial); // protocol, address, command
if (!(IrReceiver.decodedIRData.flags & IRDATA_FLAGS_IS_REPEAT)) {
for (int i = 0; i < 3; i++)
if (IrReceiver.decodedIRData.command == KEYS[i]) digitalWrite(LEDS[i], !digitalRead(LEDS[i]));
}
IrReceiver.resume();
}What the serial monitor should show
Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Uno with its sensors at their default values. Your numbers will follow your real readings, but the format should match.
Press buttons on any remote
Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Any button pressed | A line like "Protocol=NEC Address=0x4 Command=0x8" |
| Holding a button | Repeat lines marked as repeats |
| Mapped buttons | Each toggles its LED once per press |
If it does not work
Nothing printed
Check the receiver's pin order and that OUT is on D2. Try another remote.
Protocol=UNKNOWN
Some AC remotes send long frames. Use printIRResultRawFormatted to see them.
Gets warm
VCC and GND are swapped. Unplug at once.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the TV remote code reader?
Arduino Uno R3, IR receiver VS1838B, LED 5 mm red, LED 5 mm green, LED 5 mm yellow, Resistor 220 Ω × 3, Breadboard 400 points (half size) and Jumper wires male to male (40 pcs, 20 cm).
How long does the TV remote code reader take to build?
About 35 minutes for a beginner maker, in 4 steps.
How do I know the TV remote code reader works?
Any button pressed: A line like "Protocol=NEC Address=0x4 Command=0x8". Holding a button: Repeat lines marked as repeats. Mapped buttons: Each toggles its LED once per press.
Nothing printed: what should I check?
Check the receiver's pin order and that OUT is on D2. Try another remote.
Protocol=UNKNOWN: what should I check?
Some AC remotes send long frames. Use printIRResultRawFormatted to see them.
Gets warm: what should I check?
VCC and GND are swapped. Unplug at once.
