Hardware Reference
In-Depth Information
4. Run the program. The number of diamonds should be displayed and should
decrease each time the player hits one, until it reaches 0.
The 7-segment display can only display up to the number 9. If you have changed
the program so that a level has more than 9 diamonds in it, you should add an
if statement to the program so that it updates only the display if there are 9
diamonds or less left to collect.
Time-Left Indicator
Your very last task in this adventure is to update the display so the player knows that
time is running out. To do this, you will turn on the decimal point on the display. The
decimal point LED should come on when there are less than five seconds to go, giving
the player a last chance to try and complete the level.
Update the Crafty Crossing program to turn on the decimal point LED in the last five
seconds of the level:
1. After the number of seconds left is calculated in the level loop, check to see if
there are less than five seconds left. If there are, turn on the decimal point; oth-
erwise, turn it off:
secondsLeft = TIMEOUTS[level] - (time.time() - start)
if secondsLeft < 5:
display.setdp(True)
else:
display.setdp(False)
2. Run the program. When there are only five seconds left, the decimal point will
light up.
CHALLENGE
When a new level starts, use the display to flash up the level number before
showing the number of diamonds to be collected.
 
Search WWH ::




Custom Search