HOW to Decode IR Remote Control with Microbit
Overview
There is no doubt that infrared remote control is commonly seen in our daily life. It’s hard to imagine our world without it.
An infrared remote control can be used to control a wide range of home appliances such as television, audio, video recorders and satellite signal receivers.
Well, in the following let’s get a better understanding of the infrared remote control.
Infrared remote control is composed of infrared transmitting and infrared receiving systems. That is, consist of an infrared remote control, an infrared receiver module and a microcontroller that can decode. You can refer to the figure below.
The 38K infrared carrier signal transmitted by an infrared remote controller is encoded by an encoding chip inside the remote controller. It is composed of a pilot code, user code, data code, and data inversion code.
The time interval between pulses is used to distinguish whether it is a signal 0 or 1. (when the ratio of high level to low level is about 1:1, considered as signal 0.) And the encoding is just well composed of signal 0 and 1.
The user code of the same button on remote controller is unchanged. Using difference data distinguish the key pressed on the remote control.
When press down a button on the remote control, it will send out an infrared carrier signal. And when infrared receiver receives that signal, its program will decode the carrier signal, and through different data codes, thus can judge which key is pressed.
The microcontroller is decoded by an received signal 0 or 1 to determine which key is pressed by the remote control.
Components Needed
-
Micro: bit motherboard * 1
-
Keyestudio Micro bit sensor V2 expansion board * 1
-
USB cable * 1
-
Keyestudio Digital IR Receiver Module * 1
-
Keyestudio infrared remote control * 1
-
DuPont jumper wire*3
-
Premium Battery Holder 6-cell AA*1
-
1.5V AA Battery*6
Connection Diagram
Test Code
Use the library file to set test code.
Add the library file in the following block
Enter this website https://github.com/mworkfun/pxt-RI-receiver.git to search
After installing successfully, the corresponding block is in the edit the edit code column.
Note:
Some infrared remote controls don’t come with a battery and need to be configured by yourself. The battery model is CR2025.
Before testing, make sure that the infrared remote control is OK. There is a tip for you: open the camera of the mobile phone to point at the signal light of infrared remote control, then press the button of remote control. If you see a purple light flashing via the cellphone, which means that the IR remote control is OK.
Test Results
Code explanation: When the keys on IR remote are not pressed, CoolTerm monitor will refresh 0 ceaselessly; when pressed, the monitor will display the corresponding key values.
Wire up according to connection diagram. plug in external power and upload code to micro:bit, Open CoolTerm, click Options and select SerialPort, set COM port and baud rate(115200). Click OK and Connect.
Point IR remote control to IR receiver, press the button, and display the corresponding key value on serial monitor, as shown below:
Therefore, we mark the corresponding values of buttons on the remote control, as shown below.