Connect and control 7 segment displays with an Arduino using the MAX7219CNG
All my content is free.
If you feel that my videos are helping and you would like to contribute, you can toss some coins in the Tip Jar via PayPal.
Select amount then click the “Donate” button.
I’ve used and done tutorials in the past using 7 segment displays modules. These modules are great and easy to use since they have all the parts needed onboard.
But sometimes for a project you might need to create your own so that it fits in a case or you need to space them in a particular way, that a premade module won’t fit or even exist.
Most of the 7 segment modules use the MAX7219 led display driver IC.
One MAX7219 can control up to 64 individual leds or eight 7 Segment displays.
In this tutorial we will see how to connect two 2 digits 7 Segment display and control them with an Arduino UNO using the MAX7219.
7 SEGMENT DISPLAY INTRODUCTION
So what is a 7 segment display?
A 7 segment display is basicaly just a couple of regular LEDs behind a stencil. Each led lights up a particular segment and by lighting a specific combination of LEDs you can represent a number or some letters.
Most 7 segment display have 8 LEDs, one for each segment and another one used for the DP (decimal point). That’s why one MAX7219 IC can control up to eight 7 segment displays, 8×8=64 individuals LEDS.
So to connect one digit directly to an Arduino you would need 8 digital pins. That is why you want to use a LED driver like the MAX7219 that enables you to control up to 8 digits using only 3 pins.
Most 7 Segment display are common Cathode, which mean that each LED GND pins (Cathode) are connected together and the VCC+ pins (Anode) are not.
Just like a regular LED, if you reverse the polarity it will not light up.
Here’s a diagram of the 2 digit 7 Segment display we are using in this tutorial:
As you can see pin 1-5 and pin 6, 9 and 10 are connected to a specific segment.
Pin 7 and 8 (D1 and D2) are the common Cathode for each digit.
So by grounding D1 or D2 you select which digit you want to lit up a specific segment.
Of course like any LED you need to use a resistor to limit the amount of current drawn by the LED. But since we will be using the MAX7219 we will only need one resistor.
Although the MAX7219 is not the only LED driver available it’s probably the easiest to use and can control many LEDs using only one chip.
The connections are clearly identified, all you have to do is connect them to the correct pins on the 7 segment display.
You then have 3 pins to connect to the Arduino.
In addition you will need a resistor to limit the current drawn by the LEDs of the 7 segment.
Last you might want to connect some capacitors to filter out the noise from the power supply, but this is optional since I’ve built many of these without using them and never had a problem, but this is from the realm of “This is good practice”.
If you look closely you can see the pins DIG 0 through DIG 7, these are the selectors for which digit you want to select.
In our tutorial we will be using 4 of them since we have four digits.
To have a better idea on how everything is connected check out the diagram below which shows all the connections including the 10K resistor and the noise filtering capacitors.
In this tutorial we have two 2 digits 7 segment, and two switches. Each switch control one of the 7 segment to increase the value displayed when clicked.
You start by connecting the corresponding pins from the MAX7219 to the first 7 Segment, this includes D0 and D1 pin, then you connect the pins from the first 7 Segment to the second 7 Segment, but this time you connect the D2 and D3 pins from the MAX7219.
Since this tutorial has many connections, look at the diagram closely to see were everything is connected.
Don’t forget to put the 10K resistor between the MAX7219 “ISET” pin and the 5V power to prevent overcurrent.
We are using the “LedControl” library to communicate with the MAX7219 from the Arduino.
This library can be used with LED matrix or with 7 Segment displays.
In this tutorial when we click a switch, the corresponding display will increase by one, kinda like a scoreboard.
As alway check out the tutorial video to get more information.
Copy and Paste the above code/sketch in your Arduino IDE software.
Donwload the LedControl library here: