Infrared around us
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 Pulse/Edge as shown in the diagram. The IR Decoder feature is fixed on pin 2.
We can now enable the IR decoder.
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. IrRead() is used to read the received codes.
IrEnable(1) k = IrRead() Println(k)
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 IrRead() 10 times a second.
IrEnable(1) @Loop Wait(100) k = IrRead() If k = -1 Goto Loop End Println(k) Goto Loop
What other technologies use IR? Can you think of any ways to use the remote to do different things?