Basic Programs Lab 2
Goals:
To
reinforce programming learned previously
To
introduce multi-tasking
Real
World Applications:
Program
3- Burglary sensors, elevator doors, bowling foul lines
Program
4-Walking
and chewing gum, running several computer programs at once
If
you haven’t finished Lab 1, go back and do that now.
2.
We have black circular tracks in the middle of the room. Try and get your car to stay inside the circle.
It should run repeatedly coming to the line, turning around and going
forward until it sees a new line.
3.
Modify your program so it follows the black line rather than avoids it.
Program
4 – Working with two sensors & multitasking
4.
Open prog4.nqc. This program
uses two light sensors both facing the ground.
We have more pieces if you need to build a way to attach the sensor.
You
may want to spend some time studying how this program is set up, as it is more
complicated than the others we’ve used. This program works using multiple
tasks. The different tasks in the
program are written separately from one another and are started by the
“start” command in the main task (task main ()).
Once started the tasks run simultaneously ignoring the actions of the
other task.
5.
Modify the program so your car follows the S-track on the black palette.
7.
Choose one of the following:
Program your car so it follows the edge of one of the palettes we have
been working on. It should run next
to the edge the entire time; it also needs to be able to turn at the corners.
or
Design a remote for your car utilizing two bump sensors and maneuver it through the obstacle course. This can be done by one of two methods:
- one person uses both controls while blindfolded, and his/her partner dictates directions.
- each person uses one bump sensor and operates the car together.