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: common anode (5101ASR)
7-segment decoder: 74LS47N (datasheet download)
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.

BCD 7-segment decoder
Model: 74LS47N (datasheet download)
All output pins are active LOW


Array resistor (B331J)

Option 1. Connecting with a BCD 7-segment decoder

Option 2. Connecting without a 7-segment decoder
Circuit Configuration

Example Code
Download the tutorial code
TU_GPIO_LED_7segment_student.cClick here for downloadProgram a function that works as a 7-segment decoder
Option 3. Without using a 7-segment decoder on JKIT evaluation board
Circuit Configuration
JKIT - Nucleo 64: link



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.
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
Exercise Code
Last updated
Was this helpful?