"> ");
Hello everyone!
As we have seen in previous lessons, our robot can detect a black line!
In this lesson, not only we will make Edison trace the line, but also change direction and continue to move after he detects it!
In this way, he will stay continuously within the limits of the line. Of course, everything will be done by writing our program.
This program needs the operation of Edison’s line tracking sensor.
Do you remember Edison’s line tracking sensor?
You can see it if you turn our robot upside down.
It is the sensor that lets Edison see the difference between dark and light surfaces.
Nice! Let’s see now what problem we have. Then, we will find the solution to the problem.
So, the problem is:
“How do we keep the robot inside the borders?”
How are we going to solve that?
First of all, let’s make the robot drive forward. But not forever - just until it encounters with the black line.
Then let’s make him drive backward for a while... and then turn it right to avoid the line.
Let’s also check its speed.
All this must be done continuously; “forever”.
Let’s choose the right blocks in EdBlocks.
First, it drives forward...until it meets the black line...
then backwards...
and then it turns to the right.
To control the speed, we select the right block and place it on the left side of the movement blocks...
Perfect. We end the program with the loop block!
So far so good, although we haven’t finished yet.
We have to program for how many seconds we want Edison to drive backwards and for how many to be turning right.
How do we find that? The best way is by testing. I will try using the values we have already used in the previous activity.
Well done, when our robot detects the black line, it drives a little bit backward and then turns right to avoid the line. Problem solved!
Now, let’s try it at slow speed.
Now, let’s try it at fast speed.
What conclusions have you made? Answer the lesson’s questions.
I gave the same problem to my friend Stevie.
-Hello!
Stevie knows programming very well and he gave me this answer:
Ah! Stevie did not use at all the block “drive backwards”. How is it possible? Let’s see what Edison will do...
Stevie’s program works fine! Edison stays in the borders. Stevie gave us another solution for the same problem. Well done Stevie!