Explorer: Interactive pet
The lesson shows how to control the eXperiBot with simple hand movements—like a robotic pet.

Learn how to control your eXperiBot with simple hand movements. Like a robot pet that listens to you.
Model solutions
Unit 1
No program code is required for this unit. You must simply prepare the eXperiBot to start, which means:
Assemble the eXperiBot completely
Establish a connection to the app
Unit 2
Solution file to download and import into the eXperiBot Blockly app.
Lesson contents
Unit 1
Connect your eXperiBot to the app.
Proceed as follows:
Switch on your eXperiBot.
Then press the “Connect” button at the top right of the screen. Follow the instructions to connect your eXperiBot to the app.



You’ve assembled your eXperiBot and connected it to the app—now you’re ready to go!
Unit 2
You have already familiarized yourself with the Multisensor in the lessons “Follow line”, “Recognizing colors", and “Avoid obstacles”. There, you learned how the sensor measures brightness, recognizes colors, and detects objects.
This enables your eXperiBot to be a line follower, distinguish colors, and avoid obstacles.

But the Multisensor can do even more: it can also measure the distance to an object or obstacle.
The Multisensor measures distances using invisible infrared light (IR light).
The sensor emits IR light. When this light hits an object, the sensor receives the reflection.
The sensor outputs a value between 0 and 100:
0: Object is very close.
100 indicates that the sensor has detected no object or that the object is too far away.
The sensor excels at detecting distance changes in the range of approximately 10 cm to 30 cm.
If a lot of IR light bounces back, the object is close.
If little or no IR light bounces back, the object is farther away or outside the measuring range.
Attach a Multisensor at the top of the eXperiBot in the direction of travel.

Program your robot pet.
Your eXperiBot should recognize your hand and react to it:
If the distance between your eXperiBot and your hand is less than 10 cm, then your eXperiBot moves forward.
Otherwise, it turns in a circle.
To make your eXperiBot respond correctly, you need a block from the “Logic” category.
Add a suitable block to your program.
Execute the statement “drive forward” only if the condition “your hand is less than 10 cm away” is true.
If this condition is false, your eXperiBot should spin in place.
You already learned about this block in the “Follow line” lesson.
The block only executes a statement if the condition is true.
This block allows your program to make a decision.
if …
Here, your program checks a condition. The condition can only be true or false.
do …
If the condition is true, then your program executes this part.
else …
If the condition is false, then your program executes this part.
Before you insert the appropriate condition into your Conditional, consider the following questions:
When should your eXperiBot move forward?
If the distance between your hand and the Multisensor on your eXperiBot is less than 10 cm.
How can you express this condition mathematically?
Distance < 10 cm
Now create a suitable condition. Proceed as follows:
Select the appropriate block from the “Logic” category.
Select a block for distance measurement from the “Multisensor” category.
Select a number block from the “Math” category and adjust the number.
Insert the two blocks from steps 2 and 3 into the block from step 1.
If the Multisensor measures a distance of less than 10 cm to your hand, your eXperiBot should move forward.
Select a command from the “Motor” category. Your eXperiBot should execute this command when the condition is true. Insert the command into the block as appropriate.
Your program could may look like this:
If you remove your hand or the distance is greater than 10 cm, your eXperiBot should turn in a circle on the spot.
Select a second statement from the “Motor” category. Your eXperiBot should execute this statement if the condition is false, in other words, if it is not true. Insert the statement into the “if-else” block.
This block makes your eXperiBot turn on the spot.
If you want to control your eXperiBot for as long as you like with your hand movement, you must repeat this sequence infinitely.
Therefore, insert a suitable block from the “Loops” category into your program.
Consider where you need to insert the Loop into your program. Repeat the entire Sequence.
Test your program.

Pay close attention:
Does your eXperiBot turn in circles when your hand is more than 10 cm away from the Multisensor?
Does your eXperiBot immediately move forward again when your hand comes closer?
This may be due to the degree setting.
This often happens when the degree setting in the rotation block is too high.
Reduce the degree setting. You do not need 360°.
The Loop causes your eXperiBot to repeat the rotation automatically until the Multisensor recognizes your hand.
Your eXperiBot now responds to your hand movements.

