How to add a 7 segment display

This guide details how to add a display that has a 4 7-segment digits a mode changer to make it possible to cycle through the various values to be displayed and a frequency indicator that shows when the grid is under or above 50Hz.

The 4 7-segment digits are driven by a MAX7221 driver chip and the mode changer by a shift register as not to take up too many arduino digital pins although it still takes up 6. The value displayed is controlled by rotating a potentiometer.

There are already excellent guides on building the 7 segment display and the shift register for the mode changer independently of each other so I won't repeat them. This guide just details how to bring both of these parts together including some pictures of the circuits I built as a layout suggestion and the adapted Arduino code which is detailed below.

Here are the guides for the 7-segment display and shift register both in the Arduino playground:

7-segment display

Controlling a Led matrix or 7-segment displays with the MAX7219 or the MAX7221 - This is the main page that links to the two pages below.

The MAX7219 and MAX7221 Led drivers - details the 7- segment display hardware, including circuit diagrams and discussion of various factors that need to be taken in to account.

LedControl Library by Eberhard Fahle - details the Arduino library required to drive the display, including download.

Mode chooser

Serial to Parallel Shifting-Out with a 74HC595 - Started by Carlyn Maw and Tom Igoe Nov, 06. Details how to build the shift register circuit that allows us to have effectively 8 digital output pins while only using 3. Ive used 6 of the outputs for the mode chooser and 2 for the frequency indicator.

Layout suggestions

Here are a selection of pictures of the boards I built, just in case they are useful when trying to work out how to place all the components. Let me know if there's any detail that isn't so clear. More pics can be found here.

Left: Whole display, including the 7segment bit, mode chooser, frequency indicator, potentiometer and socket. Right: Whole display with the 7 segments removed.

Back of the 7 segment display and mode chooser:

Pictures of installation on wall. Communication's wire goes through a hole in the wall to the main unit.

Arduino software:

The arduino sketch here works with the display and an arduino independently of any of the other energy monitor hardware and code. The intention is to make it easier to see whats happening and to make it easier to use the code in other projects. For an example of how to add it to a full setup have a look here home energy monitor documentation page.

The main addition to the example code by Eberhard Fahle is the addition of code to make the decimal point work. The position of the decimal point depends on the number of significant figures.

Software steps:

  1. Download the sketch here: SAdisplay.tar.gz
  2. Compile and upload the Arduino sketch to the Arduino. For a guide on compiling and uploading the sketch to the Arduino have a look here.
  3. You should now see the display light up and be able to select through the values set in the sketch with the mode chooser.

Further detail on hardware

The display is made up of 3 independent parts:

1) The 7 segment display

To build this follow this link:

Controlling a Led matrix or 7-segment displays with the MAX7219 or the MAX7221 -

2) The mode chooser indicator LED's + the Large Red + Green Led's

The mode chooser LED's (the 6 small green LED's) and the 2 larger led's are all driven off the shift register. To build this part follow the following guide:

Serial to Parallel Shifting-Out with a 74HC595 

3) The mode chooser potentiometer

This potentiometer is connected directly to one of the arduino analog inputs, As you turn the potentiometer it provides a varying voltage from 0V to 5V which is read in the arduino using analogRead() The voltage is then used to select what mode is selected.

The only thing the 3 parts share in terms of hardware are the same 5V supply and ground.

  • There are 3 control lines for the 7 segment to the arduino
  • There are 3 control lines for the shift register
  • One analog line from the potentiometer

If you wish to build the above I recommend building each section individually first as per linked guides. In terms of actual order of connection to the arduino this is how I have it organised but feel free to choose different pins if you require.

 

7-segments display
Arduino pin 11 is connected to the DataIn (pin 1)
Arduino pin 12 is connected to the CLK (pin 13)
Arduino pin 13 is connected to LOAD (pin 12)
 
Shift register
Arduino -> 74HC595 

int latchPin = 9; //Pin connected to ST_CP of 74HC595 pin 12
int clockPin = 8;  //Pin connected to SH_CP of 74HC595  pin 11
int dataPin = 10;  ////Pin connected to DS of 74HC595 pin 14

 
Potentiometer
to analog input pin 0

 

AttachmentSize
SAdisplay.tar.gz2.38 KB
Polidano's picture

Re: 7 segment display

mode chooser, frequency indicator, potentiometer... can you give me more info about these, and how theyr connected please ?? :D.. i think the socket is to connect with the arduino...therefore it should be connected in a specific way???

TrystanLea's picture

Re: 7 segment display

 Hey Polidano, added a bit more info above, does it answer your question?

Polidano's picture

Re: 7 segment display

what can I say...your just number 1 :D.. I really appreciate

Guest's picture

Re: 7 segment display

can you please explain to me more how these two are connected together?? cause I got kind of lost..thanks :)

TrystanLea's picture

Re: 7 segment display

The 595 is actually independent of the 7219. The 7219 part of the circuit is used to drive the 7-segment while the 595 is used to drive the row of led's. 

Guest's picture

Re: 7 segment display

may I ask please, where are you using the 8*8 LED matrix, and why?? thanks

TrystanLea's picture

Re: 7 segment display

 there's no matrix here? :)

Guest's picture

Re: 7 segment display

but when you follow other links, there are two max722.. connected together and one of them is connected to an 8*8 LED matrix..thats why im asking why

TrystanLea's picture

Re: 7 segment display

 I think the same chip can be used for matrixes and 7segments. Im just using it for 7 segments only, so just ignore the matrixes.

Alan's picture

Re: 7 segment display

I really like this project! I'm working on a similar project so this is a big help!

Would you post a schematic of the mode chooser? I'm designing a circuit using the MAX7221, and I don't follow why you don't use another 7221/7219 for the mode indicators. I also don't at all follow how the mode chooser pot sends data back to the Arduino.