"> ");
Hello kids!
As we have already seen, a robot that moves might encounter obstacles on its way.
In this lesson, not only we will make Edison detect those obstacles, but make it change direction and keep driving after he detects them!
To do this, we will write our program. This program needs the operation of Edison’s infrared sensors.
Using the Edblocks app, we write the program you see.
What does the program say to Edison?
Let’s look at it more carefully:
The first block tells Edison to drive forward... and the second block tells Edison to wait until an obstacle is detected. When an obstacle is detected, Edison moves to the next block that tells Edison to back up.
Then, the fourth block, tells Edison to turn right.
Then the loop tells the program to start back at the first block.
Very good! We have created our program! But we haven’t finished yet.
We have to experiment to work out how much time to put in the drive backwards and turn blocks, so that our robot avoids the obstacle.
How can we find it? by trying Of course!
Let’s start by inserting the value of 3 seconds in both blocks.
Our robot has moved backwards too much. Let’s try again by inserting a lower value….
Hmm.. Exactly! This time, our robot did not drive backwards too much.
However, it turned right for too many seconds and eventually it returned to the obstacle. Let’s try a smaller time value.
Perfect! The robot has finally managed to avoid the obstacle!
If you think it is difficult to find how many seconds you have to put in each block, try again as many times as you need.
I am sure you will finally manage to do it!
I will help you a little bit...
If you remember well, in the activity “Let’s Turn” we had to find out how much time we had to put in the blocks for the robot to turn 90 or 180 degrees. Look at those values again, they will help you!