Introduction

IR, or infrared, communication is a common, inexpensive, and easy to use wireless communication technology. IR light is very similar to visible light, except that it has a slightlty longer wavelength. This means IR is undetectable to the human eye – perfect for wireless communication. For example, when you hit a button on your TV remote, an IR LED repeatedly turns on and off, 38,000 time a second, to transmit information (like volume or channel control) to an IR photo sensor on your TV.

This tutorial will first explain the inner workings of common IR communication protocols. Then we will show how to use the micro bit with the IR controller to control the RGB module

Parts Needed You will need the following parts:

About the IR

WHAT IS IR?

Infra-Red light is actually normal light with a particular colour. We humans can’t see this colour because its wave length of about 950nm is below the visible spectrum. That’s one of the reasons why IR is chosen for remote control purposes, we want to use it but we’re not interested in seeing it. Another reason is because IR LEDs are quite easy to make, and therefore can be very cheap, thus making it ideal for us hobbyists to use IR control for our own projects. We need to konw there are many more sources of Infra-Red light. The sun is the brightest source of all, but there are many others, like: light bulbs, candles, central heating system, and even our body radiates Infra-Red light. A common modulation scheme for IR communication is something called 38kHz modulation. There are very few natural sources that have the regularity of a 38kHz signal, so an IR transmitter sending data at that frequency would stand out among the ambient IR. 38kHz modulated IR data is the most common, but other frequencies can be used. When you hit a key on your remote, the transmitting IR LED will blink very quickly for a fraction of a second, transmitting encoded data to your appliance.If you were to hook an oscilloscope up to your TV remote’s IR LED, you would see a signal similar to the one above. This modulated signal is exactly what the receiving system sees. However, the point of the receiving device is to demodulate the signal and output a binary waveform that can be read by a microcontroller. When you read the OUT pin of the VS1838B with the wave from above, you will see something like the second.

Modulation

As everything that radiates heat, also radiates Infra-Red light. Therefore we have to take some precautions to guarantee that our IR message gets across to the receiver without errors.Modulation of the signal on a carrier frequency is the answer to make our signal stand out above the noise. With modulation we make the IR light source blink in a particular frequency. The IR receiver will be tuned to that frequency, so it can ignore everything else. In the picture below you can see a modulated signal driving the IR LED of the transmitter on the left side. The detected signal is coming out of the receiver at the other side.

                                                                    (Thanks to SBProjects.com for the gif and excellent IR resource!)

TECHNICAL DETAILS OF  VS1838B IR RECEIVER

THE PINOUT FOR VS1838B IR RECEIVER:

Specifications

This module consists of a 1838 IR receiver, a 1kΩ resistor and a LED. It works together with the IR transmitter module(We use an IR controller here). Compatible with popular electronic platforms like Micro bit, Arduino, Raspberry Pi and ESP8266.

Operating Voltage 2.7 to 5.5V
Operating Current 0.4 to 1.5mA
Reception Distance 18m
Reception Angle ±45º
Carrier Frequency 38KHz
Low Level Voltage 0.4V
High Level Voltage 4.5V
Ambient Light Filter up to 500LUX

ABOUT THE IR CONTROL

Infrared remotes are still the cheapest way to wirelessly control a device. We have designed the remote to be small, very simple, and low-cost.There are many different IR remote controls. all of these may have different encoding methods and number of physical buttons, and different codes received when a button is pressed.

Example

WIRING 

Connection for IR receiver:

IR receiver Micro bit
    VCC 3.3V
     – GND
     S P8

Connect the RBG module to the micro bit as below:

RGB Module Micro bit
GND GND
R P0
G P1
B P2

Run Your Script

If you are not familiar to make code, don’t worry. At first, you can enter this link: https://makecode.microbit.org/reference to get the reference of microbit block.

In this project, the extension URL is: https://github.com/osoyoo/OSOYOO_IR

If you use Micro:bit V2.0.please insert this extension URL:

https://github.com/osoyoo/OSOYOO_IR_V2.0

Either copy and paste, or re-create the following code into your own MakeCode editor by clicking the open icon in the upper right-hand corner of the editor window. You can also just download this example by clicking the download button in the lower right-hand corner of the code window.

v1-v1.5:

https://makecode.microbit.org/_KtKCrkR1eLJ1

V2 :

https://makecode.microbit.org/_HDACU3b3fXwP

TESTING RESULT

A few seconds after the download finishes, press the “CH-” button of a remote control, The RGB LED turned to red; Press the “CH” button of a remote control, The RGB LED turned to green; Press the “CH+” button of a remote control, The RGB LED turned to blue.