IoTSimulator

IR Receiver: How It Works, Wiring, and Example Code

38 kHz infrared receiver module used for decoding remote control commands.
M
Muhammad Ichsan
IR Receiver

This article is a guide about the IR Receiver. We will explain how it works, show how to wire it to an Arduino, and walk through a simple example you can use in your own projects.

IR receivers are useful when a project needs to read commands from a TV-style remote or another infrared transmitter. The module filters the incoming infrared light and turns it into a clean digital signal, which makes the remote side useful instead of just invisible light in the air.

Description

An IR receiver listens for infrared light that is usually modulated at around 38 kHz. When a matching signal arrives, the module decodes it and turns it into a digital output that the Arduino can read.

Real IR receiver module versions
Real IR receiver module versions

This makes it useful for remote-control projects, menu navigation, and simple wireless input. Instead of pressing a physical button on the board, you can point a remote at the receiver and let the sketch react to each command.

The IR Receiver and IR Remote belong together. If you want to understand the sender side too, read the IR Remote article and compare the two signal paths.

Features

Here are the main things to know about the IR Receiver:

FeatureWhat it means
38 kHz receptionListens for the common infrared carrier used by remotes.
Digital outputProduces a decoded signal the Arduino can read.
Simple wiringUsually only needs VCC, GND, and DAT.
Remote-friendlyWorks well for buttons, menus, and wireless input.
Library supportCan be used with popular IR decoding libraries.

The useful part is that the module turns invisible infrared pulses into data the sketch can react to.

How Does It Work?

The sensor watches for infrared light from a transmitter or remote. Inside the module, the light is filtered and demodulated so the Arduino sees a clean digital signal instead of raw infrared flicker.

When a button on the remote is pressed, the sender transmits a structured code, often NEC-style in beginner examples. The receiver in the image sits in the middle of the signal path: it catches the incoming IR beam, strips away the carrier noise, and outputs a digital pulse that the sketch can read.

How the IR receiver works
How the IR receiver works

In the simulator, you can use the IR remote or click the receiver to send test messages. That makes it easy to practice decoding commands before you build a real remote-controlled project. Once the output reaches Arduino, the library translates the pulse pattern into a command value, which is the part your code actually uses.

Arduino With IR Receiver

The Arduino wiring is simple once you separate the power pins from the signal pin. The receiver only needs three connections, and the sketch listens on one digital input to catch the decoded command.

SCL
SDA
AREF
GND.1
D13
D12
D11
D10
D9
D8
D7
D6
D5
D4
D3
D2
D1
D0
IOREF
RESET
3V3
5V
GND.2
GND.3
VIN
A0
A1
A2
A3
A4
A5
GND
VCC
DAT

Pin Connection

The connection map is simple: connect VCC to the supply voltage, GND to ground, and DAT to a digital input pin such as D2. The Arduino reads the decoded infrared data from that single signal line.

Pin Connection Map
IR Receiver Pin
VCC
Arduino Pin
5V
Explanation

Powers the receiver module so it can detect and filter infrared signals.

IR Receiver Pin
GND
Arduino Pin
GND
Explanation

Gives the receiver and Arduino the same electrical reference.

IR Receiver Pin
DAT
Arduino Pin
D2
Explanation

Sends the decoded command as a digital signal that the sketch can read.

Because the receiver already handles the modulation details, the sketch does not need extra analog pins or timing math. The library takes care of most of the decoding work for you.

Code

This example uses the IRremote library to read commands and print the decoded value to Serial Monitor. The IR Receiver and IR Remote use the same library because they both speak the same infrared protocol, so one side sends the coded message and the other side decodes the same format.

C++ Source
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

The sketch prints each received IR command in a short format. From there, you can compare the codes and decide which button should trigger an LED, relay, display, or menu action.

How The Code Works, Part By Part

Let's break the sketch into smaller pieces so the flow is easier to understand and easier to modify later.

Setup

The setup block starts Serial Monitor and begins the IR receiver on the chosen pin. This is where the sketch gets ready to listen for remote commands.

C++ Source
1
2
3
4
5
6
7
8

Read A Command

This part checks whether a new infrared message has arrived. If the receiver has something to decode, the sketch reads and prints it.

C++ Source
1
2
3
4

Repeat

The loop keeps listening so the Arduino can respond to more button presses. After each decode, resume() prepares the receiver for the next code.

C++ Source
1

Wrapping Up

The IR Receiver is a simple way to bring remote control input into an Arduino project. It is small, practical, and useful for menu control, wireless buttons, and other easy automation ideas.

Once you understand the DAT pin and the decode flow, the real advantage becomes clearer: the receiver gives your sketch a clean command stream, and the IR library turns that stream into button actions you can use for LEDs, relays, displays, or menu navigation.

That is why this module is such a common starting point for IR projects. It keeps the wiring simple, the code readable, and the behavior easy to test before you move the idea into a real remote-controlled build.

New

Wait! We're building more...

Our laboratory is currently preparing a lot of exciting new projects using IR Receiver. Stay tuned for the upcoming massive update!

Projects Using IR Receiver

Explore practical implementations

No official projects found for this component yet.

Muhammad Ichsanul Fadhil
About Writer

Muhammad Ichsanul Fadhil

"I'm a developer and hardware enthusiast with a passion for IoT. I love experimenting with new components and writing down everything I learn to help others build their own projects."

Share this article

Share it with your favorite channel.