www.colmac.ie
41
Construct the following program shown below.
The
Compare
command is found in
the Flow Control section of the
flowchart symbols.
It is used to compare the LDR readings
and decide whether to follow the Yes
(
Y
) or No (
N
) route in the program.
The first line connected to the
Compare command will indicate the
Yes (Y) route to follow and the second
line connected will indicate the No (N)
route to follow.
These can be swapped by right clicking
the
Compare
command and selecting
Swap Yes and No
if necessary.
We will now edit this flowchart so that it carries out the following program:
1.
Turn on the line illumination LED connected to Q3.
2.
Check if the LDR readings are more than 190 (>190).
3.
If so then drive the robot forward as it is still on the white surface.
4.
If not, i.e. less than 190 then stop the robot as it has detected the black line.
5.
The loop will ensure that the program continually checks the readings.
NOTE:
The settings used i.e. more than 190 may need to be adjusted to suit the surface and lighting
that your own robot is operating in. Use your own reading found while calibrating using
Debug Live
earlier.
The edited flowchart symbols are shown on the next page.