"What is a 7-segment display? How do you program it? How do you integrate it into your project?

Introduction

A 7-segment display is a display technique based on segments. It is mainly used to display numbers. To display letters, it is better to use an LCD screen. The 7-segment display is widely used in calculators and alarm clocks.

The 7-segment display, as its name suggests, has 7 segments. A segment is a portion of the display that allows a digit to be shown. Depending on which segments are lit, different numbers are displayed. With this display, you can show numbers from 1 to 9. The 7-segment display is coded using 8 bits.

How are the numbers represented?

The display is composed of 4 vertical segments and 3 horizontal segments. The segments are often arranged in a hexagonal shape like this, but trapezoids and rectangles are also possible. There is also a dot that allows decimal numbers to be displayed.

Here is the list of digits that can be displayed on a 7-segment display:

The letters corresponding to the pins must be connected to the 74HC595 chip. The minus (–) must be connected to the Arduino board’s ground.

Here we have an example of a connection for a 7-segment display with 6 pins on each side. Some pins (labeled with letters) are connected to the 74HC595 chip, and there is a decimal point pin for displaying decimal numbers. Finally, pins D1 to D3 are connected to the Arduino board.

  • The CD4511 Chip

The CD4511 decoder serves as a bridge between the Arduino board and the 7-segment display. It is not mandatory in your circuits; however, it helps simplify them, which is why you will see it in the diagrams throughout this course.

Here we have an example of a connection for a 7-segment display with 6 pins on each side. Some pins (labeled with letters) are connected to the 74HC595 chip, and there is a decimal point pin for displaying decimal numbers. Finally, pins D1 to D3 are connected to the Arduino board.

It allows you to display numbers on 7-segment displays without having to manually control the state of each segment. You provide the digit’s value in binary (using 4 bits), and it handles the display.

As you can see, there are letters corresponding to the connections that need to be made with the display.

Common Cathode or Common Anode?

There are two types of displays: common anode and common cathode. It’s important to understand that for current to flow, there must be a potential difference between the two points. For example, for an LED to light up, the anode must be connected to 5V and the cathode to GND. This voltage difference between the two pins creates the current.

It’s exactly the same principle here.

a) Common Anode

For this type of display, the anode is connected to 5V. This means that for current to flow, the other pins must be set to low.

b) Common Cathode

For common cathode displays, the cathode is connected to ground. This means that for current to flow, the pins controlled by the Arduino must be set to high.

For our circuits, we have chosen 7-segment displays with common cathode.

Displaying numbers on a 7-segment display

a) Simple 7-Segment Display

Now, let’s see how to display a number on a common cathode 7-segment display.

b) Using the CD4511 Chip

Now, let’s look at the same circuit with the CD4511 chip.