Anonymous

Difference between revisions of "Line follower algorithm"

From cod3v
 
(One intermediate revision by the same user not shown)
Line 25: Line 25:
== Theory ==
== Theory ==


''Zig zag'' algorithm turns the robot to right if the sensor sees white, and to left if the sensor is on the black. Or vice versa. The algorithm is easy to program using only one if block and loop block. The speed and turning value need to be considered and adjusted.
The ''Zig zag'' algorithm turns the robot to right if the sensor sees white, and to left if the sensor is on the black. Or vice versa. The algorithm is easy to program using only one if block and loop block. The speed and turning value need to be considered and adjusted.


[[File:Zigzag.png|thumb|''The Zig Zag'' algorithm.]]
[[File:Zigzag.png|thumb|''The Zig Zag'' algorithm.]]
Line 31: Line 31:
== Example Code ==
== Example Code ==


Zig Zag never drives straight. Either it turns to left or right. However, it can be made very fast, and reliable---of course depending on the line. The turning part is coded into ''if else'' block which is in the loop.
The ''Zig Zag'' never drives the robot straight. Either the robot turns to the left or to the right. However, the robot can be made very fast, and reliable---of course depending on the line. The turning part is coded into ''if else'' block which is in the loop that continuously examines the line.


== Exercises ==
== Exercises ==