Software
Design
State Diagram
Code Summary
Look for a
penny. If the penny is found,
proceed. If not, keep looking for the
penny.
Set Difficulty
Set appropriate constants
for number of allowed shots and pace car speed depending on selected difficulty
level.
Display number of shots left
Display number of laps left
Display
On your marks, get set, go sequence and check for false start. If false start was detected,
pace
car automatically wins. Otherwise,
proceed with the rest of the game.
Start the pace car
Until winner is found
If pace
car finishes a lap, then decrement and display number of laps left for
pace.
If pace
car finishes all laps first, then pace car wins (return pace car as winner).
If player
car finishes a lap, then decrement and display number of laps left for
player. If player finishes all laps first, then
player wins (return player as
winner).
Check for
ball launches.
If a ball
is launched, decrement and display number of shots (gas) left. If no gas
left, then
display out of gas sign and stop counting all subsequent shots.
Check to
see which hole ball was shot into. If
ball goes in slow down hole, then
decrease
the player’s car speed and provide feedback to user (vibrating motor, light
up LEDs,
change speedometer accordingly). If the
ball goes in small speed up
hole, then increase the player car’s speed a
little and provide feedback to user.
If the
ball goes in the large speed up hole, then increase the player car’s speed a
lot and
provide feedback to user.
Determine winner, stop player and pace car.
If player wins, dispense goodies. If pace wins, don’t dispense goodies.
Reset cars back to starting line
Code Listing
Seven Segment Display Function