Tutorial: 7-Segment Display

Using 7-Segment Display in STM32F4

We will learn how to display a decimal number (0~9) on a 7-segment display

  • Inputs:

    • Decimal number : 0~9

    • Binary: 4-bit numbers [D C B A] // (0000~ 1001)

  • Output:

    • 7-segment decoder: 7-bit numbers ( a to g)

    • 7-segment display: decimal number 0~9

We will learn how to configure the 7-segment display for different options

Option 1. With 7-segment decoder

Option 2. Without using 7-segment decoder

Option 3. Without using 7-segment decoder on JKIT evaluation board

Circuit Description

Hardware Specification

7-segment display (5101ASR)

For more detail information about 7 segment display - click here

  • Common anode: (common pin is connected to VCC)

  • Giving ‘LOW’ to the pin -> LED ON

  • Needs a load resistor for each pin(led)

Check the difference between the common cathode and common anode.

We will use common anode.

image

BCD 7-segment decoder

Model: 74LS47N (datasheet download)

  • All output pins are active LOW

Array resistor (B331J)

array resistor

Option 1. Connecting with a BCD 7-segment decoder

Option 2. Connecting without a 7-segment decoder

Circuit Configuration

image
circuit on breadbord

Example Code

Download the tutorial code

Option 3. Without using a 7-segment decoder on JKIT evaluation board

Circuit Configuration

JKIT - Nucleo 64: link

config
LED Choose
  • There are four 7-Segment Displays. You need to choose which one to use.

  • There is NO BCD decoder, you need to connect 7-segment display without using decoder.

7-segments display are Common Cathode: Giving 'High' to the pin -> LED on

1. Digital Out: 7-Segment display number
2. Digital Out: Select 7-Segment display

Digital Out

Digital Out

PB_7, PB_6, PB_5, PB_4, PB_3, PB_2, PB_1, PB_0

PC_3, PC_4, PA_11, PA_10

Push-Pull

Push-Pull

Example Code

Exercise

Create a simple code that can Select and Display a decimal number (0~9) on 7-segment display (JKIT - Nucleo 64)

  • Display Selection and Number

    • (1) Selection of the display: 0~3

    • (2) Decimal Number to display: 0~9

  • Output Display:

    • 7-segment displaying a decimal number: 0~9

If you want to display multiple 7-segment displays, you need to use a very short delay to display multiple numbers

Exercise Code

Last updated

Was this helpful?