MyRoboPathOpen Robotics Lab
Arduino Uno #12 of 35
Est. 0.75 Hours
Budget: $3 - $5
Beginner

38kHz IR Remote & Receiver Wireless Decoder

Demodulate 38kHz infrared remote control packets using a VS1838B/KY-022 receiver to trigger wireless actions.

Add effortless wireless control to any Arduino project using a handheld IR remote and 38kHz demodulator module. Decode NEC protocol command bytes cleanly with IRremote v4, map remote keys to toggle LEDs or relays, and filter key-repeat frames.

Arduino Uno R3VS1838B 38kHz IRNEC ProtocolIRremote LibraryWireless Control
38kHz IR Remote & Receiver Wireless Decoder Blueprint
38kHz IR Remote & Receiver Wireless DecoderCAD Blueprint

Key Learning Objectives & Robotics Concepts

By building and programming this project, you will master the following core engineering skills:

1Understand why IR remotes modulate data onto a 38kHz carrier wave to reject ambient infrared noise.
2Capture and decode NEC protocol command codes using the modern IRremote v4 API.
3Ignore IRDATA_FLAGS_IS_REPEAT frames so holding a key does not wildly toggle outputs.
4Map decoded remote button commands to multi-action wireless state switches.

Power Architecture & Voltage Staging

5V / 3.3V Regulated Power

The VS1838B IR demodulator draws under 1.5mA from the Arduino Uno 5V rail. An optional status LED on D8 draws ~14mA through a 220Ω series resistor. Internal 38kHz bandpass filter rejects sunlight and room lamps; keep receiver pin out of direct incandescent glare.

38kHz IR Remote & Receiver Wireless Decoder Power Architecture Schematic
Figure: Regulated Arduino Uno supply rails, current budget, and component protection.Power Schematic

Bill of Materials (BOM) & Hardware Components

Bill of Materials for 38kHz IR Remote & Receiver Wireless Decoder
ComponentSpecifications & AlternativeQtyApprox Cost
Arduino Uno R3ATmega328P @ 16MHz1$8.00
VS1838B / KY-022 38kHz IR Receiver38kHz carrier demodulator, 8–12m range1$1.20
NEC Infrared Remote Control17-key or 21-key CR2025 battery remote1$2.00
5mm LED + 220Ω ResistorWireless switched load indicator1$0.15

Electrical & System Architecture

Connect IR Receiver VCC (+) to 5V, GND (-) to GND, and OUT (S) to Arduino D2. Wire a controlled LED (+220Ω) to D8 for wireless toggle demonstration.

Figure: Complete Arduino Uno R3 pin-to-pin wiring schematic for 38kHz IR Remote & Receiver Wireless Decoder.
Figure: Complete Arduino Uno R3 pin-to-pin wiring schematic for 38kHz IR Remote & Receiver Wireless Decoder.Wiring Schematic

Autonomous Behavior & Finite State Machine (FSM)

Deterministic Arduino loop handling VS1838B / KY-022 38kHz IR Receiver + Remote acquisition, filtering, and real-time output updates.

Figure: Firmware execution flow and state transitions for 38kHz IR Remote & Receiver Wireless Decoder.
Figure: Firmware execution flow and state transitions for 38kHz IR Remote & Receiver Wireless Decoder.Control Algorithm

Step-by-Step Physical Assembly & Wiring Tutorial

Follow each of the 5 sequential milestone stages with technical photos, wiring checks, and pre-flight tests.

1

Remove Battery Pull-Tab & Verify Receiver Pinout

Duration: 5 Mins

Pull the clear plastic insulator out of the IR remote battery tray and inspect receiver pins.

38kHz IR Remote & Receiver Wireless Decoder hardware layout diagram
Stage 1: VS1838B / KY-022 38kHz IR Receiver + Remote hardware inspection & pinout overview.Stage 1 Diagram
Step Action Checklist:
  • Pull out the plastic battery tab on the bottom of the remote control.
  • Point the remote at a smartphone camera and press a button—you should see a faint violet glow on screen.
  • Verify KY-022 / VS1838B pins (bare VS1838B dome facing you: OUT, GND, VCC).
Engineering & Tuning Tip: The smartphone camera trick verifies the IR remote battery and emitter LED in 2 seconds!
2

Wire IR Receiver to D2 & Indicator LED to D8

Duration: 5 Mins

Connect power, ground, receiver data to D2, and the target LED to D8.

38kHz IR Remote & Receiver Wireless Decoder breadboard wiring check diagram
Stage 2: Breadboard layout & Arduino Uno pin-to-pin wiring audit.Stage 2 Diagram
Step Action Checklist:
  • Wire IR Receiver VCC → 5V, GND → GND, and OUT → D2.
  • Wire D8 → 220Ω resistor → LED anode → cathode to GND.
  • Aim the black IR dome unobstructed toward your testing position.
Engineering & Tuning Tip: Reversing VCC/GND on a VS1838B overheats it quickly—verify bare pinout vs breakout silkscreen carefully.
3

Install IRremote v4 Library

Duration: 5 Mins

Install "IRremote" by shiriff / ArminJo via Library Manager.

38kHz IR Remote & Receiver Wireless Decoder power rail protection diagram
Stage 3: Supply rail check (USB 5.0V Regulated Rail (≈1.5mA receiver)) and circuit protection verification.Stage 3 Diagram
Step Action Checklist:
  • Open Arduino IDE Library Manager and search "IRremote".
  • Install the latest IRremote v4.x library.
  • Note that v4 uses IrReceiver.begin() and IrReceiver.decodedIRData.command.
Engineering & Tuning Tip: Old tutorials using results.value fail on IRremote v4—our code below uses the clean modern v4 API.
4

Capture Your Remote's Command Hex Codes

Duration: 10 Mins

Upload the decoder sketch, press buttons on your remote, and observe exact hex commands.

38kHz IR Remote & Receiver Wireless Decoder serial telemetry verification diagram
Stage 4: Firmware upload & 115200 baud Serial Monitor verification.Stage 4 Diagram
Step Action Checklist:
  • Upload the production sketch and open Serial Monitor at 115200 baud.
  • Press keys 1, 2, OK, and Power on your remote and note their Hex Command values.
  • Verify key 1 (0x45 or 0x0C) and key 2 (0x46 or 0x18) update to match your remote.
Engineering & Tuning Tip: Any household TV remote (Sony, Samsung, NEC) also decodes cleanly with IRremote!
5

Test Wireless Range & Repeat Filtering

Duration: 5 Mins

Verify crisp single-press toggling across the room without repeat-frame chatter.

38kHz IR Remote & Receiver Wireless Decoder live operational logic diagram
Stage 5: Live operational logic flow & calibration verification.Stage 5 Diagram
Step Action Checklist:
  • Press and hold a toggle button—confirm it triggers only once per press.
  • Test line-of-sight range up to 5 meters and bounce signals off a white ceiling.
  • Record command hex codes for all keys you plan to automate.
Engineering & Tuning Tip: Always call IrReceiver.resume() at the end of every decode block or the receiver stops listening.

Subsystem Benchtop Verification Scripts

Test each hardware subsystem independently before deploying the full autonomous firmware.

1Bench Diagnostic: VS1838B / KY-022 38kHz IR Receiver + Remote Hardware Check

Subsystem Diagnostic

Minimal standalone sketch to verify pin wiring and signal response for VS1838B / KY-022 38kHz IR Receiver + Remote before running the full project firmware.

Arduino IDE Diagnostic ScriptC++ / Arduino
// Diagnostic: Print Every Decoded IR Protocol & Hex Command
#include <IRremote.hpp>
void setup() {
  Serial.begin(115200);
  IrReceiver.begin(2, ENABLE_LED_FEEDBACK);
}
void loop() {
  if (IrReceiver.decode()) {
    Serial.print("Protocol="); Serial.print(getProtocolString(IrReceiver.decodedIRData.protocol));
    Serial.print(" | Cmd=0x"); Serial.println(IrReceiver.decodedIRData.command, HEX);
    IrReceiver.resume();
  }
}
Expected Output: Protocol=NEC | Cmd=0x45 (varies by remote button pressed).

Complete Production Firmware

Full working C++ source code with pin mappings, non-blocking timers, and FSM avoidance routines.

arduino_uno_ir_remote_receiver_decoder.ino
arduino_uno_ir_remote_receiver_decoder.inoArduino C++
/**
 * Project 12: 38kHz IR Remote Wireless Controller (IRremote v4)
 * Board: Arduino Uno R3 | Pins: D2 (IR OUT), D8 (LED)
 * Library: IRremote by ArminJo (v4.x)
 */
#include <IRremote.hpp>

const uint8_t IR_PIN = 2;
const uint8_t LED_PIN = 8;
bool ledState = false;

void setup() {
  Serial.begin(115200);
  pinMode(LED_PIN, OUTPUT);
  IrReceiver.begin(IR_PIN, ENABLE_LED_FEEDBACK);
  Serial.println(F("IR Remote Decoder Ready. Press any key..."));
}

void loop() {
  if (!IrReceiver.decode()) return;

  // Ignore NEC repeat frames when button is held down
  if (!(IrReceiver.decodedIRData.flags & IRDATA_FLAGS_IS_REPEAT)) {
    uint16_t cmd = IrReceiver.decodedIRData.command;
    Serial.print(F("Key Command: 0x"));
    Serial.println(cmd, HEX);

    // Common NEC starter-kit codes (adjust from Serial printout if needed)
    if (cmd == 0x45 || cmd == 0x0C) {        // Key '1' -> LED ON
      ledState = true;
    } else if (cmd == 0x46 || cmd == 0x18) { // Key '2' -> LED OFF
      ledState = false;
    } else if (cmd == 0x1C || cmd == 0x40) { // Key 'OK' -> Toggle
      ledState = !ledState;
    }
    digitalWrite(LED_PIN, ledState ? HIGH : LOW);
  }

  IrReceiver.resume();
}

Firmware Architecture Explanation:

  • Uses modern IRremote v4 (IRremote.hpp) with onboard LED feedback on pin 13.
  • Filters out IRDATA_FLAGS_IS_REPEAT packets so holding a remote button causes only one clean action.
  • Prints every received command byte in hex so any brand of IR remote can be mapped in seconds.

Operational Verification & Pin State Matrix

1Double-check all 4 Arduino Uno pin connections against the wiring schematic before plugging in USB.
2Upload the Bench Diagnostic sketch first and confirm Serial Monitor at 115200 baud matches: Protocol=NEC | Cmd=0x45 (varies by remote button pressed).
3Upload the complete production sketch and verify every condition in the operational truth table below.

Input Signal vs. System Output Truth Table:

Operational truth table for 38kHz IR Remote & Receiver Wireless Decoder
Input / StatePin / SignalDetected ConditionExpected Output
Key 1 (0x45)D2 NEC FrameTurn ON CommandD8 LED = HIGH
Key 2 (0x46)D2 NEC FrameTurn OFF CommandD8 LED = LOW
Key OK (0x1C)D2 NEC FrameToggle CommandInvert D8 LED State

Engineering Troubleshooting Matrix

Engineering troubleshooting matrix for 38kHz IR Remote & Receiver Wireless Decoder
ProblemLikely CauseDiagnostic CheckEngineering Solution
Nothing prints in Serial Monitor when pressing keysDead remote battery, plastic tab still inserted, or reversed receiver powerView remote LED through smartphone camera while pressingRemove battery tab / replace CR2025 cell and verify receiver pinout.
Prints 0x0 or UNKNOWN protocolLoose signal jumper or ambient sunlight flooding receiverShade the receiver dome and retest at 30cm distanceShield receiver from direct sunlight and check D2 connection.
Compilation error about IRrecv / decode_resultsMixing IRremote v2 syntax with v4 libraryCheck installed library version in IDEUse IrReceiver.begin() and IrReceiver.decode() as shown above.

Engineering Challenges & Upgrades

Take your build to the next level with these progressive engineering upgrades:

Level 1IR Brightness Dimmer

Map Volume + / Volume - keys to step a PWM LED on D9 up and down in 10% increments.

Level 24-Digit IR Passcode Lock

Require pressing keys 1-2-3-4 within 10 seconds to unlock a Green LED or SG90 servo.

Level 3Wireless RGB Mood Controller

Map keys 1–6 to switch Project 11 RGB LED between Red, Green, Blue, Cyan, Amber, and Rainbow.