Introduction to a problem

How can we control a robot? There are multiple ways to interact with robots - using visual clues, voice commands and even your brain waves! One of the most basic ways, suitable even for relatively simple robots is to use a remote control device. This way you can give robot commands fro distance and it will react to messages from remote control according to the code it has running on its control chip. How to implement this in our Bittle? Let’s find out!

Explaining the knowledge

Infrared radiation

You are very likely familiar with simple infrared remote control unit, often it is used to control home appliances, such as TV, fan or an air conditioner. These remote control units use infrared light as a medium of communication. Infrared waves, or infrared light, are part of the electromagnetic spectrum.
Lesson 5 IR Sensor - Remote Control - 图1
People encounter Infrared waves every day; the human eye cannot see it, but humans can detect it as heat.

Infrared remote control units

When we press a button on the remote, the infrared LED in the remote emits a specific sequence of infrared pulses - we cannot see them with our naked eye, but if it was regular LED, we would see them as very fast flashes.
WxQFvZw.jpg
Each sequence when it reaches IR receiver module is decoded into a number, which then can be used to determine an action.
IR remotes use LED lights to transmit their infrared signals. This results in a few limitations of the technology. Since light is used to transmit the signal, IR remotes require line-of-sight, which means you need an open path between the transmitter and receiver. This means that IR remotes won’t work through walls or around corners. They also have a limited range of about 10 meters.

While your home appliances already have a software inside them, that determines how exactly the appliance should react to a certain code from remote control and you cannot change the set program, Bittle is open to your creativity. The Infrared receiver module is integrated into Bittle control board. You can see it in the bottom part of the robot.
Lesson 5 IR Sensor - Remote Control - 图3
In this lesson we will learn how to use Bittle’s default remote control to control BIttle and possibly will use other types of remote control for the same purpose.

Solving a problem

The blocks for using remote control are located under System tab.
5-1.png

Task 1: Stop Bittle with IR Remote

Every time we want to use remote control we need to place Infrared Receiver started block first, which initiates the IR receiver and decodes the incoming data. The second block is Bool type block, which means it return True or False, depending on if condition inside of the block(button of standard remote is pressed) being True or False. Let’s try it out in simple code:
5-2.png
5-1

The code above will make Bittle crawl forward continuously and stop when you press PLAY/PAUSE button on the remote control.

Note: Make sure to point IR Remote at Bittle and keep relatively close distance between remote control unit and the robot.

Lesson 5 IR Sensor - Remote Control - 图6

Task 2: Different movements

Now let’s try more complex code, that will allow us to control the direction of BIttle trotting and stop it with different buttons:
5-3.png
5-2 5-1实拍.mp4 (6.26MB)

Task 3: Use other remote control units

Let’s try using a different remote, if you have any lying around. First of all, we need to determine what are the codes for different buttons. Upload this code to Bittle, open Serial monitor and press some buttons! Remember to note which button correspond to which number.
5-4.png
5-3
image.png
Now when we know the code for specific buttons, we can compare it with actual values received and according to the result of the comparison (True or False) control the robot using the same IF-ELSE (or IF) blocks:
5-5.png
5-4

You can find comparison operators under Operators tab. Try it with your own remote control!

Expanding the knowledge

Find out code values for Bittle’s standard remote control with the code above.