Thursday session due: Nov. 2; Tuesday session due: Nov. 7.
This is a team assignment. Individuals do not need to work on their own solution. Team members should work together, and should avoid trying to solve the problem on their own.
For this lab you need to build a LEGO car, and program it to follow a dark line on a white surface, and avoid obstacles. Your car will need at least two light sensors mounted and pointing downwards towards the floor, and one or two contact switches up front to detect when it runs into something. The light sensors usually need to be quite close to the surface of the floor, within a quarter inch or so.
There are many white sheets of cardboard with sample black lines on them, back near the cabinets.
Your car will need light sensors near the ground to detect the line. The lines are generally about an inch wide. Placement of your light sensors can be crucial to how well your car performs. You do not necessarily need to use all three light sensors. Indeed, the easiest solution might only use two. (If you can make a robust solution with just one sensor, however, then you are smarter than I am!)
This lab isn’t really new – you already know how to do all of this, because you did the LED blinking program with the light sensors. Since the LEDs are the same as the motor output (PORTB), you just need to think about which motor you want to go in which direction based on the values of the light sensors. You should not have a delay loop anymore, but should immediately recheck the light sensors, and continually update the direction of your car.
You can download this program which will read your light sensors and print out their hexadecimal values to the gdl comm window. You can move the sensors over various surfaces and see what values you get, and this may help you in programming your car.
For obstacle avoidance, your car must minimally do the following: if while following the line it runs into an obstacle, it should back up so that it is not touching the obstacle anymore, and wait for 1 second. It should then continue following the line forward. Alternatively, your car could try to go around the obstacle. If your car can do this and require the line and continue following it forward, your team will receive one extra point. Be sure to tell the TA or myself which method your car will use when we check it out.
For this assignment, you must