Skills Mapping
Dr P. Shields - 19/02/2024
Schedule:
Tuesday, Week 21-22 .

Creating a Stopwatch


In this task you are required to write a program to make your switches and seven segment display act as a stopwatch.

You should only attempt the advanced functionality after you have demonstrated the basic functionality.

Specifications

Basic functionality

  • Your programme should display zero until one switch is pressed (START).
  • The display should then count up indicating how many seconds have passed.
  • When the same switch is pressed again (STOP) the display should stay constant showing the measured time.
  • If pressed again (START) the display should count up from the current value.
  • When a second switch is pressed (RESET) the display should return to zero.
  • If the display reaches 9, the counter should continue counting again from 0 until the STOP switch is pressed.

Advanced functionality

You should attempt the advanced functionality in the following order:

  1. Add a second & third 7-segment display to record the time with 0.1 and 0.01 second resolution, to count from 0 to 9.99 secs. (Remote students using Proteus should instead aim for 0 to 99.9 secs)

    Note: since the number of pins is limited, you will have to share pins. This can be done by connecting another single pin to the common anode. Controlling the voltage on this pin will switch the whole 7-segment display on or off.

    Since the LEDs can switch on and off much quicker than the eye can detect, one can alternate between controlling different 7-segment displays: e.g. during one instruction cycle the first is switched on with a number 7, the next cycle the first is switched off and a second is switched on with a number 2 – both numbers will look persistent to the eye. The disadvantage is that the LEDs will appear dimmer than if they were on for all of the time.

  2. Add a lap function to the reset switch. If this is pressed whilst the stopwatch is running, the display should show the lap time, but still continue timing in the background. If the STOP switch is then pressed, the final time should be displayed. If instead the RESET/LAP switch is pressed again, the new lap time should be displayed, whilst continuing timing in the background etc.