Explorer: Recognizing colors
The lesson teaches how the eXperiBot recognizes colored markers and performs appropriate actions based on them.

Learn how to tell your eXperiBot to recognize colors and perform specific actions.
Model solutions
Unit 1
No program code is required for this unit. You just need to make the eXperiBot ready to start, which means:
Assemble the eXperiBot completely
Establish a connection to the app
Draw or stick a black line with green markings on the floor
Unit 2
First, attach the Multisensor to the front bottom of the eXperiBot. The Multisensor’s module LED should then light up blue.
Solution file to download and import into the eXperiBot Blockly app.
Unit 3
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!
Show your eXperiBot which way to go—draw your own line with green markers.
Plan the green markers directly. Don’t draw a continuous line, but leave 2 cm gaps for the green markers.
Prepare the line: Take a black pen and draw a straight line with gaps on a large, light-colored piece of cardboard.
The line should be at least 3 cm wide and at least 50 cm long.
Or: Use black tape and stick a straight line with gaps on the floor.
Add colored markers: Color the gaps green.
Use the picture as a guide so that your line and the green markers are clearly visible.

Unit 2
You have already learned about the Multisensor in the lessons “Avoiding obstacles” and “Line follower”.
You learned how it recognizes objects and how it measures brightness.
This ability enables your eXperiBot to avoid obstacles and follow a line.
But the Multisensor can do even more: it also recognizes the color of a surface.
Knowledge update: the Multisensor for color recognition
The Multisensor uses color filters to distinguish colors.
If a lot of light reaches the green filter and only a little reaches the other filters, the sensor recognizes that the surface is green.
Attach the Multisensor to the front bottom of the eXperiBot in the direction of travel.

Your eXperiBot must first follow the black line reliably as a line follower so that it can recognize the green markers correctly.
To do this, use your program from the “Line follower” lesson and adapt it.
If you have not yet completed the “Line follower” lesson, first create a program that allows your eXperiBot to follow the black line. You can find tips in the “Line follower” lesson.
Open your “Line follower” program.
Copy the code and paste it into the editor here.
With this program, your eXperiBot follows the black line until both IR sensors detect a white surface. Then your eXperiBot knows that it has reached the end of the line.
Now your eXperiBot should follow the line until it detects the color green.
Adjust your “Line follower” program. Use a suitable block from the “Multisensor” category.
Your eXperiBot repeats the Line follower statements until its Multisensor detects a green marker.
As soon as the Multisensor sees green, the repetition stops.
Test your program by placing your eXperiBot at the start of your line.
Make sure both IR sensors of the Multisensor are aligned at the start.

Check whether your eXperiBot follows the line and stops before a green marker.
If not, adjust your program.
Change the condition in the following block and test your program again.

Your eXperiBot will now follow the line until it reaches a green marker.
Now your eXperiBot needs to know what to do when it stops repeating—i.e., when it is in front of a green marker.
First, make your eXperiBot play a sound, then move it forward over the green marker so it returns to the dark line.
To do this, add the appropriate blocks from the “Powerbrain” and “Multisensor” categories to your program.
When your eXperiBot detects a green marker, the repetition stops.
So think about where your newly inserted blocks need to be placed.
Your eXperiBot should only move forward a short distance. In doing so, it will cross the green mark, allowing its Multisensor to detect the dark line again. Only then can the eXperiBot continue to follow the line.
Test your program by placing your eXperiBot at the start of your line.

If your program is working correctly, your eXperiBot will play a sound at the green marker and then move forward to the dark line.
Now your eXperiBot should not only execute these statements once, but repeatedly—i.e., every time it encounters another green marker.
Adjust your program accordingly.
Think about how your eXperiBot can execute the statements repeatedly. To do this, you need a block that repeats all statements over and over again.
Test your program. To do this, place your eXperiBot at the start of your line.
Check whether your eXperiBot follows the line, plays a sound at a green marker, and then continues on its way. Make sure that your eXperiBot repeats this process until it reaches the end of the line.

Let your eXperiBot drive forward over the green mark for just a brief moment.
Your eXperiBot follows the line, plays a sound at the green marker, and then continues on its way. It reliably repeats this until it reaches the end of the line.

Unit 3
Draw a new black line.
Or extend your existing line.
Add colored markers in red, blue, and green to the line.

Add to your existing program so that your eXperiBot follows the line until its Multisensor detects red, blue, or green.
To do this, insert the appropriate blocks from the “Logic” and “Multisensor” categories.
Your eXperiBot should follow the black line until it detects red, blue, or green. As soon as the Multisensor detects red, blue, or green, the Loop stops.
You can also simply place the block several times in a row.
Your eXperiBot already knows that when it detects a green marker, it plays a sound and moves forward briefly over the green marker.
You still need to program how your eXperiBot should react to blue and red.
Blue marker: Your eXperiBot rotates once around itself.
Red marker: Your eXperiBot also rotates around itself and plays a sound.
In order for your eXperiBot to respond appropriately to colors, you need a block from the “Logic” category.
The block you are looking for only executes a statement if the condition is true.
Here’s a reminder - this is how your eXperiBot should respond:
Green marker: Your eXperiBot plays a sound.
Blue marker: Your eXperiBot rotates once around itself.
Red marker: Your eXperiBot also rotates around itself and plays a sound.
Now add the appropriate conditions and statements to your Conditional branch.
Use the appropriate blocks from the “Multisensor” and “Powerbrain” categories.
A Conditional statement helps your eXperiBot make decisions. The block only executes a statement if the condition is true.
A rotation around itself means that your eXperiBot turns completely in a circle. This corresponds to 360°.
After your eXperiBot executes its statements for green, blue, and red, it should move forward briefly. This will bring it back to the black line.
Add this to your program accordingly.
Test your program by placing your eXperiBot at the start of the line.
Check whether your eXperiBot follows the line and reacts correctly to the colored markers:
Green: play a sound
Blue: turn around once
Red: turn and play a sound
Make sure your eXperiBot travels to the end of the line.

Your eXperiBot follows the black line and reacts correctly to all colored markers.

Bonus unit 1
Think about your own actions that you want your eXperiBot to perform at the colored markers.
Adjust your program.
Here are a few ideas for your own actions: for example, changing speed, driving backwards, turning twice, playing a special sound, or driving fast or slow.
Test your program. To do this, place your eXperiBot at the start of your line.
Check whether your eXperiBot follows the black line and reacts correctly to the colored markers.

Your eXperiBot follows the black line and reacts correctly to all colored markers.

