C-Handout 6 – Assignment
Pre-lab Assignment for
Thursday 10/12
This is to be handed in at
the beginning of Lab on the 12th.
(10/10/00 Page 4)
Name:___________________________________________
Write
a program that moves the robot around the floor.
- Make sure your program
is well commented so it can be understood by the grader.
- If neither bumper
switch is closed, go straight ahead.
- If a bumper switch
closes, back up and steer away from the side that was hit.
- If both bumpers are
closed, back up and turn away from the obstacle (the turn should be more
extreme than the previous case).
- Make sure your program
is well commented so it can be understood by the grader.
Fill
in the outline on the other side of this page.
- Make sure your program
is well commented so it can be understood by the grader.
- You will turn in your
program at the beginning of lab.
- Make a copy of your
program before lab, so you will have it during lab. You will be implementing, and debugging,
a similar program during lab.
- I don’t expect a
perfect program, but I want to make sure you have thoroughly though out
all the issues and difficulties before coming to lab.
- There are many ways to
write this program, and no single correct answer. Be original – just make sure your code
is clear and well commented.
- Use at least one
function besides “main()”. The
function can do anything: back up, turn away from an obstacle, read the
bumpers, go forward…
- Assume the left bumper
is connected to digital(7), the right bumper to digital(8). The function “digital()” returns a 0
(FALSE) if the bumper is depressed, and a 1 (TRUE) if it is not.
- You may work in groups,
but make sure that everybody in the group is participating. If you know more C than others in your
group, you should make sure everybody else understands what is going on,
and that you are not simply dictating to the others in the group. If you know less C than the others in
your group, make sure that you ask questions if you don’t understand something.
- Use extra pages if
necessary.
Make
sure your program is well commented so it can be understood by the grader.
/*Global
variable declarations (if any) and functions go here*/ (
void
main() {
/*Variable
declarations go here*/
ao(); /*Turn
all motors off*/
printf(“\nPress Start to begin.”);
start_press(); /*Wait for start
button*/
/*Initialization code goes here (if any)*/
while (1) { /*Repeat these lines
(to closing brace, }) forever*/
/*The
main body of your program goes here*/
}
}