Infrared (IR)
Infrared (IR)
Many electronic devices communicate without wires.
For example:
- TV remote controls
- Air conditioners
- Media players
- Projectors
- Smart home devices
Most of these devices use Infrared (IR) communication.
Infrared communication uses invisible light signals to transfer information between devices.
The Infrared category allows a D1 R32 to:
Receive signals from remote controls
Detect button presses
Read command codes
Transmit infrared signals
Control other IR-enabled devices
Create programmable remote-control systems
Build wireless robot controllers
Introduction
Imagine pressing a button on a TV remote.
The television immediately changes channel.
No wires are involved.
What happened?
The remote transmitted an invisible infrared signal.
The television received that signal and interpreted it as a command.
The exact same process can occur between a remote control and the D1 R32.
Remote Control
↓
Infrared Signal
↓
IR Receiver
↓
D1 R32
The D1 R32 can also perform the opposite operation:
D1 R32
↓
IR Transmitter
↓
Infrared Signal
↓
Television / Device
This allows your projects to both receive and send infrared information.
What Is Infrared (IR)?
Infrared is a type of light that cannot be seen by the human eye.
Devices use this invisible light to transmit information.
Instead of sending text or pictures, infrared usually sends:
- Commands
- Button presses
- Device instructions
- Control signals
Everyday Examples
Examples of devices that commonly use IR include:
Television remotes
Air conditioner remotes
Audio systems
DVD players
Projectors
Some robotics systems
Why Use IR?
IR communication allows devices to communicate wirelessly over short distances.
Examples include:
- Turning LEDs on and off
- Controlling robots
- Reading remote buttons
- Creating programmable remotes
- Sending commands between devices
Understanding IR Communication
All IR systems use the same basic communication pattern.
Transmitter
↓
Infrared Signal
↓
Receiver
The transmitter sends information.
The receiver detects and interprets that information.
Infrared Category
[INSERT CATEGORY IMAGE HERE: Infrared Category]
Figure 13.1 – Blocks available in the Infrared (IR) category.
The category is divided into two major sections:
IR Receive
Receives and interprets infrared signals.
IR Send
Transmits infrared signals.
Learning Model
The category can be understood using two workflows.
Receiving
SETUP
↓
RECEIVE
↓
READ
↓
ACT
Sending
SETUP
↓
TRANSMIT
↓
CHECK
Part 1: Receiving Infrared Signals
IR Receive Setup
[INSERT BLOCK IMAGE HERE: IR Receive Setup]
Before receiving signals, the IR receiver must be configured.
Conceptually:
Choose Protocol
↓
Connect Receiver
↓
Receive Signals
Actual Generated Python
Clu-Blocks Pro creates an infrared receiver object.
import irremoteThe generated code depends on the selected protocol.
NEC 8-bit
ir_rx = irremote.NEC_RX(26,8)NEC 16-bit
ir_rx = irremote.NEC_RX(26,16)NEC
ir_rx = irremote.NEC_RX(26,0)RC5
ir_rx = irremote.RC5_RX(26)| Protocol | Generated Python |
|---|---|
| NEC 8-bit | irremote.NEC_RX(26,8) |
| NEC 16-bit | irremote.NEC_RX(26,16) |
| NEC | irremote.NEC_RX(26,0) |
| RC5 | irremote.RC5_RX(26) |
Setup first. Receive second.
Why Setup First?
Imagine trying to listen to a radio that isn't turned on.
You would hear nothing.
The same applies to IR communication.
The receiver must be configured before it can detect information.
IR Protocols
The receiver can be configured to understand different communication formats.
Examples include:
- NEC 8-bit
- NEC 16-bit
- NEC
- RC5
For beginners, the important idea is:
Receiver Setup
↓
Protocol
↓
Receive Data
Receiving Infrared Data
[INSERT BLOCK IMAGE HERE: Get Received Code]
After a signal is received, information can be extracted from it.
Conceptually:
Receive Signal
↓
Extract Information
↓
Use Information
Actual Generated Python
The block can access four confirmed positions of the received code.
ir_rx.code[0]ir_rx.code[1]ir_rx.code[2]ir_rx.code[3]| Selection | Generated Python |
|---|---|
| Position 1 | ir_rx.code[0] |
| Position 2 | ir_rx.code[1] |
| Position 3 | ir_rx.code[2] |
| Position 4 | ir_rx.code[3] |
Detecting New Data
[INSERT BLOCK IMAGE HERE: Data Received?]
Before reading information, a program can check whether new IR data is available.
Conceptually:
Signal Received?
↓
True / False
Actual Generated Python
ir_rx.any()Example:
IF Signal Received
↓
Read Command
This prevents the program from trying to read information when no signal is present.
Enabling and Disabling the Receiver
[INSERT BLOCK IMAGE HERE: Receive Control]
The receiver can be enabled or disabled.
Actual Generated Python
Enable receiving:
ir_rx.enable(True)Disable receiving:
ir_rx.enable(False)| State | Generated Python |
|---|---|
| Enable | ir_rx.enable(True) |
| Disable | ir_rx.enable(False) |
Enabled
Listening for Signals
Disabled
Ignoring Signals
Receive Timeout
[INSERT BLOCK IMAGE HERE: Receive Timeout]
The timeout setting controls how long the receiver waits for communication.
Actual Generated Python
ir_rx.timeout(1000)Example:
1000 milliseconds
Conceptually:
Wait for Signal
↓
Signal Arrives?
↓
Yes / Timeout
Understanding Hexadecimal Commands
Infrared remotes often use hexadecimal command codes.
Example:
0x45
The:
0x
prefix indicates hexadecimal notation.
IR Remote Control Button Codes
[INSERT IMAGE HERE: IR Remote Control]
Figure. IR remote control used in Clu-Blocks Pro exercises.
Complete Remote-Control Reference
| Button | Hex Raw | Hex Command |
|---|---|---|
| 1 | 0xba45ff00 | 0x45 |
| 2 | 0xb946ff00 | 0x46 |
| 3 | 0xb847ff00 | 0x47 |
| 4 | 0xbb44ff00 | 0x44 |
| 5 | 0xbf40ff00 | 0x40 |
| 6 | 0xbc43ff00 | 0x43 |
| 7 | 0xf807ff00 | 0x07 |
| 8 | 0xea15ff00 | 0x15 |
| 9 | 0xf609ff00 | 0x09 |
| * | 0xe916ff00 | 0x16 |
| 0 | 0xe619ff00 | 0x19 |
| # | 0xf20dff00 | 0x0D |
| UP | 0xe718ff00 | 0x18 |
| LEFT | 0xf708ff00 | 0x08 |
| RIGHT | 0xa55aff00 | 0x5A |
| DOWN | 0xad52ff00 | 0x52 |
| OK | 0xe31cff00 | 0x1C |
Course Rule
Use Hex Command values unless the exercise specifically requires the full raw code.
Example:
Button 1
Hex Raw: 0xba45ff00
Hex Command: 0x45
First IR Experiment
The first IR activity should focus only on identifying commands.
Step 1
Press a remote button.
Step 2
Receive the command.
Step 3
Display the command through Serial.
Step 4
Compare it with the reference table.
Example:
Press Button 1
↓
Receive Command
↓
0x45
↓
Serial Monitor
Using Commands to Control Projects
Once commands can be identified, Logic blocks can be added.
Example:
Received Command
↓
Equals 0x18?
↓
True
↓
Move Robot Forward
Another Example:
Received Command
↓
Equals 0x52?
↓
True
↓
Move Robot Backward
Part 2: Sending Infrared Signals
IR Send Setup
[INSERT BLOCK IMAGE HERE: IR Send Setup]
Before transmitting infrared signals, the transmitter must be configured.
Conceptually:
Choose Configuration
↓
Set Power
↓
Transmit
Actual Generated Python
NEC
ir_tx = irremote.NEC_TX(26,False,90)NEC Inverted
ir_tx = irremote.NEC_TX(26,True,90)RC5
ir_tx = irremote.RC5_TX(26,90)| Configuration | Generated Python |
|---|---|
| NEC | NEC_TX(26,False,90) |
| NEC Inverted | NEC_TX(26,True,90) |
| RC5 | RC5_TX(26,90) |
Sending Commands
[INSERT BLOCK IMAGE HERE: Send Command]
The send command block transmits structured infrared information.
Actual Generated Python
ir_tx.transmit(0,0,0)The block contains:
- Command Code
- Address Code
- Control Bit
Conceptually:
Command
+
Address
+
Control
↓
Transmit
Sending Raw Codes
[INSERT BLOCK IMAGE HERE: Send Raw Code]
Sometimes a project already knows the exact code it wants to send.
Actual Generated Python
ir_tx.transmit(raw=0x1234)Conceptually:
Hex Code
↓
IR Transmitter
↓
Receiving Device
Sending Pulse Sequences
[INSERT BLOCK IMAGE HERE: Send Pulses]
Pulse transmission allows exact timing information to be sent.
Actual Generated Python
ir_tx.transmit(
pulses=[9000,4500,563,563]
)Example pulse sequence:
9000, 4500, 563, 563
Conceptually:
Pulse Pattern
↓
Infrared Signal
Advanced Topic: Pulse sequences should usually be introduced after students understand command-based transmission.
Command vs Raw vs Pulses
| Method | Generated Python | Use |
|---|---|---|
| Command | transmit(command,address,control) | Structured commands |
| Raw | transmit(raw=...) | Raw hexadecimal code |
| Pulses | transmit(pulses=[...]) | Explicit pulse timing |
Hex Command values are usually the easiest way for beginners to work with IR communication.
Checking Transmission Status
[INSERT BLOCK IMAGE HERE: Transmit Status]
Programs can check whether the transmitter is busy.
Actual Generated Python
ir_tx.busy()Conceptually:
Still Sending?
↓
Yes / No
Using Serial While Learning IR
For this category, Serial communication should remain central.
Step 1
Press a remote button.
Step 2
Receive the command.
Step 3
Send the command to the Serial Monitor.
Step 4
Compare it with the reference table.
Step 5
Use that command in Logic.
Learning Pattern
RECEIVE
↓
OBSERVE
↓
IDENTIFY
↓
COMPARE
↓
ACT
This makes invisible communication visible.
IR Receive vs IR Send
| IR Receive | IR Send |
|---|---|
Creates ir_rx | Creates ir_tx |
| Detects signals | Creates signals |
| Reads commands | Sends commands |
Uses any() | Uses transmit() |
Uses enable() | Uses transmitter setup |
| Uses timeouts | Uses transmit status |
| Remote → D1 R32 | D1 R32 → Device |
Infrared vs Radio
| Infrared | Radio |
|---|---|
| Uses invisible light | Uses radio signals |
| Usually line-of-sight | Usually does not require line-of-sight |
| Common in remotes | Common in robotics |
| Remote-control focused | Device-to-device focused |
Key Vocabulary
| Term | Definition |
|---|---|
| Infrared (IR) | Invisible light used for communication |
| IR Receiver | Device that detects infrared signals |
| IR Transmitter | Device that sends infrared signals |
| Protocol | Communication format used by IR devices |
| NEC | Common infrared communication protocol |
| RC5 | Another infrared communication protocol |
| Command | Instruction carried by an IR signal |
| Hexadecimal | Base-16 number format |
| Raw Code | Complete IR communication value |
| Pulse Sequence | Timing pattern used in IR communication |
Summary
In this lesson, you learned how infrared communication allows devices to exchange information using invisible light.
You explored how to:
Configure an IR receiver
Receive remote-control information
Identify hexadecimal command codes
Configure an IR transmitter
Send infrared commands
Use remote controls to trigger actions
Build programmable remote-control systems
Understand the difference between receiving and transmitting infrared signals
Infrared communication powers many everyday devices such as televisions, air conditioners, projectors, and media players. By learning how to receive, interpret, and transmit infrared signals, you can create projects that interact with the same technology used in real-world electronics.
Key Takeaway
Infrared communication allows a D1 R32 to receive and transmit invisible light signals, just like a programmable remote control.
By learning to receive commands, identify button codes, transmit signals, and trigger actions, you can create projects that interact with real-world electronic devices and build your own custom remote-control systems.
