Infrared communication

Author: Yisong Xu, Si Xu

When you press the mBot1/mCore1 onboard button, mBot1/mCore1 will send communication signals and sound, and mBot2/mCore2 receives the signal then sounds and lights.

Hardware requirements:

mBot/mCore Control Panel


Upload the program to Arduino

Example program download:

Infrared communication (sending).sb2


Infrared communication (receiving).sb2


Example programs
* To complete this example, you need to prepare 2 mBot/mCore. Upload Program 1 to mBot1/mCore1 and Program 2 to mBot2/mCore2.

Program 1 – Sending
Upload to mBot1/mCore1
Program 2 – Receiving
Upload to mBot2/mCore2
programming for kids programming for kids


Script description
This example is implemented by using the mCore onboard IR receiver and IR emitter.
Prepare two mBot/mCore, and upload Program 1 to mBot1/mCore1 while Program 2 to mBot2/mCore2.
Program 1 – Sending a message: Simply press the on-board button and mBot1/mCore1 sounds and sends a message, which is sent by the on-board infrared emitter. The message content can be customized . In this example the message is set as “s”.
Program 2 – Receive messages: As long as the message “s” is received, the mBot2/mCore2 control board will send out red light and the buzzer sounds (imitating the “hit” effect).
If there are other mBots, you can use the example program to communicate and interact between multiple mBots/mCores as long as the messages sent/received are the same.


Knowledge points
Point 1 Characters in infrared communication:
The message defined in Block programming for kids is used as a signal. Fill in English characters or strings which occupies as less space as possible to avoid error when the program is complicated.

Point 2 programming for kids Block use
programming for kids block is used to determine whether a signal is matched to a infrared communication. It cannot be replaced by a calculation block  in this case.

Point 3 To implement Program 2 you need to drag the communication block out
Use  block. You need to select “extensions” – “Communication” in the mBlock menu to drag the Communication block out in the robot module area.
programming for kids point 3


Extended tasks
Change the script: When mCore1 senses a strong light, it will send another message When mCore2 receives the message, it will show “full resurrection” with sound and light effects.


Attached -mCore main control board Infrared communication diagram

programming for kids point

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

—— More examples