Due Date: a week after your lab session.
This assignment is a simple program running on your Miniboard. Your board will need one working switch connected to it and one light sensor. You need to write two versions of the same program, one that uses the switch and one that uses the light sensor.
The program should turn the red motor lights on, one at a time, for a 1/4 second each. Thus, the red row of motor LED lights should blink in sequence, one second per iteration over the four lights. Timing is important and will be part of the grade. The LEDs should blink in the order of increasing motor numbers – i.e., motor 1, motor 2, motor 3, motor 4, motor 1, …. In essence it is like a string of blinking Christmas lights.
For the switch version, if the switch is pressed your program should blink the green motor lights instead, as long as the switch is held down. When the switch is released, the program should go back to blinking the red lights. For the light sensor version, if a dark surface passes over the sensor (such as your thumb!), your program should blink the green motor lights, until the dark surface is removed.
When your program switches between red and green lights, either red-to-green or green-to-red, the sequencing must be maintained correctly. That is, if the third red light is on and your program notices the switch depressed or the light sensor darkened, then it should turn on the fourth green light next. So no matter which color of light is on, the 1-2-3-4-1-2-3-4... sequence should never be broken.
You do not need to detect a switch/sensor and switch to the other color in the middle of the 1/4-second one period. You can wait until it is time to switch the next light in sequence, and then check your switch/sensor.
The program is a team assignment. Each team will work together on it, and each person will submit the team’s solutions.
Your program should include a subroutine that simply delays for a 1/4 of a second. It does not need to have any parameters or return values. You will have to use a counting loop (probably on a 16-bit register) in the subroutine to delay for a time period.
Also, each team should work on building a car. This is not part of the lab grade, but is something you should begin anyway.
The design is, essentially, up to you. But keep in mind the tasks that it will have to do:
Most cars in the past have used a set of three light sensors facing downward, and placed horizontally across the width of the car.
Some designs that placed the sensors under the middle of the car have had problems because it is too dark under the center of the car. Placing the sensors where they have good ambient light seems to work best.
You should finish the following items in this lab: