Project 004: 4-Digit Seven-Segment Display

4-Digit Seven-Segment Display

The 4-digit seven-segment display consists of 12 pins. Among these pins, 8 are assigned to the 8 LEDs present in each seven-segment display, which are responsible for segments A to G and the decimal point (DP). The remaining 4 pins represent the 4 digits from D1 to D4.

4 digit 7 segment LED display pinout

Each of the four digits present in the module has a common connection point. The same segment numbers in each digit are concatenated together, allowing each digit to be controlled independently, and reducing the number of required GPIO pins to 12 instead of 32.

Circuit

Circuir 4Ditgi7Seg s

Timer

You are designing a timer with the following functions:

  • The timer has two switches: SW1 and SW2.
  • SW1 starts and pauses the timer, while SW2 resets and stops the timer.
  • The timer can count from 00:00 to 59:59, then stop.

The timer operation is as below:

  • Check the states of SW1 and SW2 every 20 ms.
    • If SW2 is active, set both the minute and second digits to 0, and pause the timer
    • otherwise, if SW1 is pressed, toggle the pause variable
  • Display one digit of the seven-segment every 8 ms.
  • Toggle the decimal point (Seg_DP) of the second digit (D2) every 500 ms
  • Increase the second digit by 1 every 1000 ms, and update the minute digit accordingly.
  • If the timer reaches 59:59, pause the timer.

Pin configurations

DevicePort.Pin Signal TypeModuleDirectionDrive Mode