Make sure you can change the number of lines your program counts by changing the value in a variable so that your program is easily modified to count any number of lines. (Hints: Be careful about using variable names that make sense. Techniques to consider are wait for a short period after hitting a dark line before looking for a dark line, or wait for a period after hitting a dark line then see if the sensor is seeing bright and count it if so, or record the value now then record the value again after a short period and count it if the positive difference exceeds a reasonable dead band, or...)
Write down an outline of what you want your program to do before actually programming it.
Save this program as m6LineCounter then download and test your program.
Challenge: Modify your program to count say the first three lines, stop and backup to the start. Move the starting position and see if your robot can still get back to the new start point after counting three lines. Change the value in the variable holding the number of lines to count to 4 and repeat. See if your robot is smart enough to count four lines and then turn around and go back to close to the point of origin.
Plan for storing the number of lines to count:
Plan for counting lines:
Plan for determining how to backup the same distance driven forward:
Write down your comments recording any
problems and their solution or any pertinent details learned during
execution of this mission.