BBC micro:bit Counter using a 7-Segment Display

7-segment-displayThe aim of this challenge is to create a countdown timer, controlled by a BBC micro:bit that will display the numbers on a screen using a 7-segment display. A lot of electronic devices use this approach to display numbers on a LED or LCD screen. (Watch, alarm clock, calculator etc.)

Typically 7-segment displays consist of seven individual coloured LED’s (called the segments). Each segment can be turned on or off to create a unique pattern/combination. Each segment is identified using a letter between A to G as follows:

7segments

The following truth table shows which segments need to be on to display the digits from 0 to 9:

Digit A B C D E F G
tmp-0 1 1 1 1 1 1 0
tmp-1 0 1 1 0 0 0 0
tmp-2 1 1 0 1 1 0 1
tmp-3 1 1 1 1 0 0 1
tmp-4 0 1 1 0 0 1 1
tmp-5 1 0 1 1 0 1 1
tmp-6 1 0 1 1 1 1 1
tmp-7 1 1 1 0 0 0 0
tmp-8 1 1 1 1 1 1 1
tmp-9 1 1 1 1 0 1 1

Step 1: The electronic circuit


7-segment-display-connectionsTo complete this challenge you will need:

  • 1 breadboard
  • 8 resistors of 220Ω each
  • 1 7-segment display (common anode)
  • 1 BBC micro:bit
  • 1 micro:bit edge connector
  • 20 wires

Here is the circuit that you will need to re-create:
micro-bit-7-segment

Step 2: Python Code

To program your BBC micro:bit you will use the Python editor and copy and paste the following code:

Your 7-segment display should display all the digits, counting up from 0 to 9.

Your Challenge


countdown_animatedUpdate the code to:

  • Create a count down timer, going from 9 to 0.
  • Allow the user to pause and restart the countdown timer using the A and B buttons of the micro:bit.
Share Button