JS Infrared


What is Infrared and how is it used?

Infrared is basically a color our eyes cannot perceive but is around us everywhere. Infrared is used in many different products, such as telescopes to see distant planets and gases. Weather satellites use infrared to show us images of storms. Infrared is also used in night vision to see objects in the dark.

In the IR Receiver module and remote control, infrared is used to communicate between the remote control and the IR Receiver.  The invisible infrared light emits from the remote control when a button is pressed. This light turns on and off very fast. The IR Receiver has a light sensor, which can see these light flashes and then convert those pulses into information. Since an infrared module must ‘see’ the invisible light it only works within the same room. IR light does not go through walls.

There are thousands of remote and receiver options but we will use a BrainPad Microcomputer with IR Receiver from the BrainClip kit.

Connect the BrainPad edge as shown in the diagram. The IR Decoder feature is fixed on pin 2.

We can now enable the IR decoder.

await BrainPad.Infrared.Enable(1);

Each time the button on the remote control is pressed a new number is sent to the IR receiver, which then the decoder reads and stores internally, up to 16 presses. Infrared.Read() is used to read the received codes.

ir = await BrainPad.Infrared.Read();

The codes received can come from any remote with similar protocols. A remote press will result Infrared.Read() in a “code” and no press will result in a -1.

We will build a program that Infrared.Read() 10 times a second.

await BrainPad.Infrared.Enable(1);
    await BrainPad.System.Wait(100);
    var k = await BrainPad.Infrared.Read();
    if(k == -1){
    await BrainPad.System.Println(k);


What other technologies use IR? Can you think of any ways to program the remote to do different things?

Content Licensing

Twitter Feed
Hot off the press!