Infrared (IR)
Your "Programmable Remote Control"
Receiving and Transmitting Infrared Signals
What it is
The Infrared (IR) category contains blocks for receiving and transmitting information using infrared signals.
Clu-Blocks Pro provides two complementary groups:
- IR Receive for detecting and reading incoming infrared signals.
- IR Send for transmitting infrared commands, pulses, or raw codes.
What it does
The confirmed Clu-Blocks Pro generation allows a program to:
- Configure an IR receiver.
- Select different receive protocols or NEC formats.
- Obtain different parts of a received IR code.
- Enable or disable reception.
- Check whether IR data is available.
- Configure a receive timeout.
- Configure an IR transmitter.
- Select different transmission configurations.
- Send command information.
- Send pulse sequences.
- Send raw IR codes.
- Check whether the transmitter is busy.
Example
A remote control can send a command to the D1 R32:
IR Remote → IR Signal → IR Receiver → D1 R32
The D1 R32 can also transmit infrared signals:
D1 R32 → IR Transmitter → IR Signal → Receiving Device
Think of IR communication as invisible light carrying coded information from a transmitter to a receiver.
Fun Guide to IR Communication Blocks (Clu-blocks Pro)
What it does: Sends and receives infrared signals.
Send: Control TVs, air conditioners
Receive: Read existing remote controls
Important! IR blocks let your robot send and receive invisible light signals just like a remote control. You can use it to control devices, react to button presses, or even talk to other robots!
The category is easiest to understand as two families:
RECEIVE → READ / CONTROL
and
SETUP → TRANSMIT → CHECK
IR Receiving Blocks
| Block | What it does | Dropdown options | What the options mean |
| Sets up the IR receiver on a pin | Socket Type: NEC_8, NEC_16, NEC_other, RC5 | Choose the IR protocol your remote uses | |
| Reads data from the IR signal | command, address, raw, pulses | Choose what part of the signal to read command is most common | |
| Temporarily stops receiving | enable, disable | Pause = stop listening, Recover = start listening again | |
| Checks if a new signal was received | — | Returns true if a new command came in | |
| Sets how long to wait for a signal | — | If no signal comes in during tdis time, it times out |
IR Sending Blocks
| Block | What it does | Dropdown options | What the options mean |
| Sets up the IR transmitter | Socket Type: NEC, Samsung, RC5 | Choose the protocol your target device understands | |
| Sends a full IR signal | — | You define the command, address, and control bit manually | |
| Sends a custom pulse pattern | — | Advanced use great for mimicking unknown remotes | |
| Sends a raw hexadecimal signal | — | Use tdis if you know the exact code to send | |
| Checks if sending is done | — | Returns true when the signal has finished transmitting |
Quick Tips for Students
- Use setupIRreceive before trying to read signals it’s like turning on the ears.
- Use command code to get the button press most remotes send tdis.
- Use callback functions to make your robot react instantly like turning on a light when you press a button.
- Use IRsend to control TVs, fans, or other IR devices just match the protocol and code.
- Use println to discover what your remote sends then reuse tdose codes to send them back!
1. Setting Up the IR Receiver
[ INSERT BLOCK IMAGE HERE: IR Receive Setup ]
Clu-Blocks Pro uses:
Python
import irremote
and creates an IR receiver named:
Python
ir_rx
The actual generation confirms four configurations.
| IR Selection | Generated MicroPython |
|---|---|
| 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) |
For example:
Python
ir_rx = irremote.NEC_RX(26,8)
The pin number depends on the pin selected in the block.
Setup first. Receive second.
2. NEC and RC5
The real generation confirms that Clu-Blocks Pro supports more than one IR receive configuration.
NEC 8-bit
Python
irremote.NEC_RX(26,8)
NEC 16-bit
Python
irremote.NEC_RX(26,16)
``
NEC
Python
irremote.NEC_RX(26,0)
RC5
Python
irremote.RC5_RX(26)
For beginner exercises using your supplied remote control, students do not need to master every protocol immediately.
The important concept is:
IR Receiver Setup → Protocol / Format → Receive Data
3. Getting Information from the Received Code
[ INSERT BLOCK IMAGE HERE: IR Get Code ]
The actual generation confirms four available code positions:
Python
ir_rx.code[0]
Python
ir_rx.code[1]
Python
ir_rx.code[2]
Python
ir_rx.code[3]
Therefore, the selector is not simply a generic “get command” operation. The block actually selects one of four positions from the received IR code information.
This is an important correction from our earlier version.
For the student manual, these possibilities should be documented according to the names displayed in the actual drop-down, while the technical reference can show:
Selection → code[index]
⭐ IR Remote Control Button Codes
This reference is essential for the IR exercises.
Each button on the supplied IR remote produces a specific code. For convenience and readability, the Clu-Blocks Pro exercises will normally use the shorter Hex Command value.
[ INSERT IMAGE HERE: IR Remote Control ]
Figure. IR remote control used in the 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 | 0x7 |
| 8 | 0xea15ff00 | 0x15 |
| 9 | 0xf609ff00 | 0x9 |
| * | 0xe916ff00 | 0x16 |
| 0 | 0xe619ff00 | 0x19 |
| # | 0xf20dff00 | 0xd |
| UP | 0xe718ff00 | 0x18 |
| LEFT | 0xf708ff00 | 0x8 |
| RIGHT | 0xa55aff00 | 0x5a |
| DOWN | 0xad52ff00 | 0x52 |
| OK | 0xe31cff00 | 0x1c |
Hex Raw vs. Hex Command
The remote-control reference contains two hexadecimal representations.
Hex Raw
The Hex Raw column contains the complete supplied remote code.
For example, button 1:
Plain Text
0xba45ff00
Hex Command
The Hex Command is the shorter command value we will normally use in the exercises.
For button 1:
Plain Text
0x45
Therefore:
Button 1
Hex Raw → 0xba45ff00
Hex Command → 0x45
Clu-Blocks Pro Course Rule: Unless an exercise specifically requires the complete raw code, use the Hex Command value.
This makes the programs considerably easier for beginners to read.
Quick Remote-Control Reference
For exercises, students can use this more compact version:
| Button | Hex Command | Button | Hex Command |
|---|---|---|---|
| 1 | 0x45 | 2 | 0x46 |
| 3 | 0x47 | 4 | 0x44 |
| 5 | 0x40 | 6 | 0x43 |
| 7 | 0x7 | 8 | 0x15 |
| 9 | 0x9 | 0 | 0x19 |
| * | 0x16 | # | 0xd |
| UP | 0x18 | DOWN | 0x52 |
| LEFT | 0x8 | RIGHT | 0x5a |
| OK | 0x1c |
4. Enabling and Disabling IR Reception
[ INSERT BLOCK IMAGE HERE: IR Receive Control ]
The real Clu-Blocks Pro generation confirms two states:
Python
ir_rx.enable(True)
and:
Python
ir_rx.enable(False)
Therefore:
| State | Generation |
|---|---|
| Enable | enable(True) |
| Disable | enable(False) |
Conceptually:
Enable → Receiver Active
Disable → Receiver Inactive
This is more precise than our previous description of the visible pause selector.
5. Checking Whether IR Data Is Available
[ INSERT BLOCK IMAGE HERE: IR Data Received ]
The block generates:
Python
ir_rx.any()
This provides the receive-data check implemented by the Clu-Blocks Pro IR library.
Conceptually:
IR Receiver → Data Available? → Result
This can be combined with Control:
IF IR data available → Read IR information
6. IR Receive Timeout
[ INSERT BLOCK IMAGE HERE: IR Timeout ]
The visible example:
1000 ms
generates:
Python
ir_rx.timeout(1000)
This configures the timeout value used by the IR receiver operation.
The important relationship is:
Timeout Field → Milliseconds → IR Receiver
7. Setting Up the IR Transmitter
[ INSERT BLOCK IMAGE HERE: IR Send Setup ]
Clu-Blocks Pro creates the transmitter as:
Python
ir_tx
The real code confirms three transmission configurations.
NEC
Python
ir_tx = irremote.NEC_TX(26,False,90)
NEC with Inverted Setting
Python
ir_tx = irremote.NEC_TX(26,True,90)
RC5
Python
ir_tx = irremote.RC5_TX(26,90)
The visible example uses transmission power:
90
The conceptual sequence is:
Setup Transmitter → Select Configuration → Set Power → Transmit
8. Normal and Inverted NEC Configuration
The actual generation tells us that the NEC transmitter includes a Boolean configuration value:
Python
False
or:
Python
True
Therefore, the two NEC selections correspond to distinct generated configurations:
Python
NEC_TX(pin, False, power)
and:
Python
NEC_TX(pin, True, power)
For the beginner explanation, students only need to recognize that the selector provides two NEC transmitter configurations.
The internal significance of the Boolean parameter does not need to be taught until an exercise requires it.
9. Sending a Command
[ INSERT BLOCK IMAGE HERE: Send Command ]
The structured transmit block generates:
Python
ir_tx.transmit(0,0,0)
The block contains three visible values:
- Command code
- Address code
- Control bit
Conceptually:
Command + Address + Control → IR Transmit
This is the structured form of transmitting an IR command.
10. Sending Pulse Data
[ INSERT BLOCK IMAGE HERE: Send Pulses ]
The supplied example generates:
Python
ir_tx.transmit(
pulses=[9000,4500,563,563]
)
This sends an explicit pulse sequence.
The example pulse list is:
Plain Text
9000, 4500, 563, 563
Conceptually:
Pulse Sequence → IR Transmitter → IR Signal
Advanced Concept: Students do not need to work with pulse sequences when first learning an IR remote. Hex Command should remain the easier introduction.
11. Sending a Raw IR Code
[ INSERT BLOCK IMAGE HERE: Send Raw Code ]
The supplied example generates:
Python
ir_tx.transmit(raw=0x1234)
This sends the supplied raw value through the IR transmitter operation.
The example uses:
Plain Text
0x1234
The 0x prefix indicates hexadecimal notation, a concept students already encounter in the remote-control table.
Command vs. Pulses vs. Raw
This distinction is important.
| Transmission Method | Confirmed Generation | Main Idea |
|---|---|---|
| Command | transmit(command,address,control) | Structured command information. |
| Pulses | transmit(pulses=[...]) | Explicit pulse sequence. |
| Raw | transmit(raw=...) | Raw hexadecimal IR value. |
Students should not treat these three representations as interchangeable.
For beginners:
Hex Command → easiest for remote-control exercises
Later:
Structured Send → Raw → Pulses
can be explored when needed.
12. Checking the IR Transmitter
[ INSERT BLOCK IMAGE HERE: IR Transmit Status ]
The interface presents this as a transmission-status block.
The real generation confirms:
Python
ir_tx.busy()
Therefore, the technically accurate explanation is:
Provides the busy-status operation of the IR transmitter.
This is better than saying the generated MicroPython literally asks “transmit done?”, because the real generated method is:
Python
busy()
Students should understand the relationship as:
Transmit → Check Transmitter Status
Receiving a Remote-Control Command
For the exercises using your remote control, the basic learning flow should be:
PRESS BUTTON
↓
IR SIGNAL
↓
IR RECEIVER
↓
READ COMMAND INFORMATION
↓
HEX COMMAND
↓
SERIAL PORT
↓
PC
Students can first observe:
Plain Text
0x45
and use the reference table to identify:
Button 1
This makes the invisible IR communication observable.
From Hex Command to Action
After students can reliably receive and recognize the command, Logic and Control can be added.
For example:
IR Remote
↓
Receive Command
↓
Compare with 0x18
↓
TRUE / FALSE
↓
IF TRUE
↓
UP Action
The same structure can be used for:
LEFT → 0x8
RIGHT → 0x5a
DOWN → 0x52
OK → 0x1c
This is an excellent progression from simple communication to remote control.
Using Serial Port While Learning IR
For this category, I strongly recommend keeping Serial communication central to the exercises.
Step 1
Press a remote button.
Step 2
Receive the IR information.
Step 3
Send the relevant received value to the PC.
Step 4
Compare the value with the remote-control reference.
Step 5
Use the identified Hex Command in Logic.
This gives students the progression:
RECEIVE → OBSERVE → IDENTIFY → COMPARE → ACT
rather than immediately hiding the incoming information inside a complicated control program.
IR Receive vs. IR Send
| IR Receive | IR Send |
|---|---|
Creates ir_rx | Creates ir_tx |
| NEC / RC5 receiver configurations | NEC / RC5 transmitter configurations |
| Reads code information | Sends command information |
| Enable / disable receiver | Configure transmission |
Check incoming data with any() | Send structured command |
| Configure timeout | Send pulses |
| Send raw code | |
Check transmitter with busy() |
The overall communication concept remains:
IR TRANSMITTER → IR SIGNAL → IR RECEIVER
Quick Guide for Students
Do I want to receive IR?
Start with IR Receive Setup.
Are we using the course remote?
Begin with the appropriate NEC receive configuration shown in the exercise.
Do I need to know whether information arrived?
Use the block that generates:
ir_rx.any()
Do I need the received code information?
Use the Get Received Code block with the appropriate selector.
Do I need to temporarily enable or disable receiving?
Use the receive-control block:
Enable / Disable
Do I need a receive timeout?
Use IR Receive Timeout.
Do I want to transmit IR?
Start with IR Send Setup.
Do I want to send command information?
Use Send Command.
Do I need a pulse sequence?
Use Send Pulses.
Do I need a raw code?
Use Send Raw Code.
Do I need transmitter status?
Use the block generating:
ir_tx.busy()
Quick Reference
| Family | Confirmed Operation | Main Idea |
|---|---|---|
| Receive Setup | NEC_RX(...,8) | NEC 8-bit configuration. |
| Receive Setup | NEC_RX(...,16) | NEC 16-bit configuration. |
| Receive Setup | NEC_RX(...,0) | NEC configuration using the generated 0 option. |
| Receive Setup | RC5_RX(...) | RC5 receiver configuration. |
| Received Code | code[0] | First confirmed code position. |
| Received Code | code[1] | Second confirmed code position. |
| Received Code | code[2] | Third confirmed code position. |
| Received Code | code[3] | Fourth confirmed code position. |
| Receiver Control | enable(True) | Enable reception. |
| Receiver Control | enable(False) | Disable reception. |
| Data Status | any() | Check incoming IR availability. |
| Timeout | timeout() | Configure receive timeout. |
| Send Setup | NEC_TX(...,False,...) | Confirmed NEC transmitter configuration. |
| Send Setup | NEC_TX(...,True,...) | Alternate confirmed NEC configuration. |
| Send Setup | RC5_TX(...) | RC5 transmitter configuration. |
| Send Command | transmit(0,0,0) | Transmit command/address/control information. |
| Send Pulses | transmit(pulses=[...]) | Transmit a pulse sequence. |
| Send Raw | transmit(raw=...) | Transmit a raw code. |
| TX Status | busy() | Obtain transmitter busy status. |
