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

BlockWhat it doesDropdown optionsWhat the options mean
Sets up the IR receiver on a pinSocket Type: NEC_8, NEC_16, NEC_other, RC5Choose the IR protocol your remote uses
Reads data from the IR signalcommand, address, raw, pulsesChoose what part of the signal to read command is most common
Temporarily stops receivingenable, disablePause = 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

BlockWhat it doesDropdown optionsWhat the options mean
Sets up the IR transmitterSocket Type: NEC, Samsung, RC5Choose 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 SelectionGenerated MicroPython
NEC 8-bitirremote.NEC_RX(26,8)
NEC 16-bitirremote.NEC_RX(26,16)
NECirremote.NEC_RX(26,0)
RC5irremote.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

ButtonHex RawHex Command
10xba45ff000x45
20xb946ff000x46
30xb847ff000x47
40xbb44ff000x44
50xbf40ff000x40
60xbc43ff000x43
70xf807ff000x7
80xea15ff000x15
90xf609ff000x9
*0xe916ff000x16
00xe619ff000x19
#0xf20dff000xd
UP0xe718ff000x18
LEFT0xf708ff000x8
RIGHT0xa55aff000x5a
DOWN0xad52ff000x52
OK0xe31cff000x1c

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:

ButtonHex CommandButtonHex Command
10x4520x46
30x4740x44
50x4060x43
70x780x15
90x900x19
*0x16#0xd
UP0x18DOWN0x52
LEFT0x8RIGHT0x5a
OK0x1c  

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:

StateGeneration
Enableenable(True)
Disableenable(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:

  1. Command code
  2. Address code
  3. 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 MethodConfirmed GenerationMain Idea
Commandtransmit(command,address,control)Structured command information.
Pulsestransmit(pulses=[...])Explicit pulse sequence.
Rawtransmit(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 ReceiveIR Send
Creates ir_rxCreates ir_tx
NEC / RC5 receiver configurationsNEC / RC5 transmitter configurations
Reads code informationSends command information
Enable / disable receiverConfigure transmission
Check incoming data with any()Send structured command
Configure timeoutSend 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

FamilyConfirmed OperationMain Idea
Receive SetupNEC_RX(...,8)NEC 8-bit configuration.
Receive SetupNEC_RX(...,16)NEC 16-bit configuration.
Receive SetupNEC_RX(...,0)NEC configuration using the generated 0 option.
Receive SetupRC5_RX(...)RC5 receiver configuration.
Received Codecode[0]First confirmed code position.
Received Codecode[1]Second confirmed code position.
Received Codecode[2]Third confirmed code position.
Received Codecode[3]Fourth confirmed code position.
Receiver Controlenable(True)Enable reception.
Receiver Controlenable(False)Disable reception.
Data Statusany()Check incoming IR availability.
Timeouttimeout()Configure receive timeout.
Send SetupNEC_TX(...,False,...)Confirmed NEC transmitter configuration.
Send SetupNEC_TX(...,True,...)Alternate confirmed NEC configuration.
Send SetupRC5_TX(...)RC5 transmitter configuration.
Send Commandtransmit(0,0,0)Transmit command/address/control information.
Send Pulsestransmit(pulses=[...])Transmit a pulse sequence.
Send Rawtransmit(raw=...)Transmit a raw code.
TX Statusbusy()Obtain transmitter busy status.