Home made large 7 segment LED display

As you may recall, I had a post on the large (10 cm or 4″) 7 segment display earlier, when I made one for the escape room countdown timer. That was a fun project which did exactly what it was asked to do.

There were two little issues with it however. First, it was a 12 volt display, requiring a separate power supply. Second, the system is a common anode display as opposed to the more common one that has a common cathode for the segments. These two requirements also dictated the selection of the shift register. It had to work on common anode, and be capable of passing 12 volts.

The chip of choice in that project was the MAX7219 as discussed in the post above. It wasn’t as easy to find as the ubiquitous 74HC595, which is supplied in Arduino starter boxes and costs mere cents if purchased separately. MAX7219 is also more expensive. Both of these shift registers have a footprint that works fine with basic breadboards.

As for the LEDs I thought to use the red 5V units which cost you next to nothing and can be sourced anywhere. These have a diameter of 5mm, and when I made the 3D printed 7 segment base, I provided 21 holes in it, ready to be plugged with LEDs. All you need to do is to solder the anodes of the three LEDs in each segment together, then the cathodes too. The anodes of each segment will then be given a male jumper wire, but all cathodes are connected together and finally solder in a male jumper to provide the common ground to all LEDs.

The base

The base can be printed on any 3D printer. It is a STL file that can also be cut out of plywood if you have access to one. I use PLA material but it plays no role. Layer height ban be as high as 0.3mm with infill set at 10%.

As there are no stresses whatsoever for the print to withstand, a quick print setting will do nicely. There is also a stand for the four display units, but that requires a wide printer. I will provide a small stand for printing one for each display.

Get the STL file here.

The wiring of one shift register

Each 74HC595 has 16 pins. The unit has a notch to identify the installation direction. When the notch is pointing up, the pins are counted counterclockwise, starting at 1 and ending with 16 on the top of the right side.

Pins of the 74HC595

Display pin 0, which in this device corresponds to the top segment or A, is pin 15 on the 74HC595. This is somewhat counterintuitive in my mind, but the manufacturer is unlikely to accommodate me in this and redesign the chip.

Segments identified

Pins 1 to 7 correspond to the other segments, with the 7 being the decimal point. As I will use a separate Arduino pin for decimals and another for displaying a colon between two displays, you can leave the shift register pin Q7 disconnected.

The VCC pins 10 and 16 are for voltage, OE and Gnd pins 8 and 13 for ground. That leaves four special pins to connect. In my application, these are the data in pin, clock pin, latch pin, and data out pin. Data in is Arduino’s pin 11, clock pin is 13, and latch pin is 12.

Think of the latch pin as a lock on the door. When it is pulled high, the door to the data pin is open, and the clock pin times the transfer of one byte of data. Then the latch pin is pulled down, and the door closes, resulting in the pins of the shift register being high or low as a result of the byte sent in.

For example, sending 01011010 to the shift register gives you the number 2 on your display. I use the magnificent library ShiftRegister74HC595 to manage the digits, but more on that later.

Soldering the LEDs

A word of caution: LEDs don’t take heat too well. When you are soldering, try to be quick when the soldering iron touches the LED pins, but apply enough heat to avoid cold joints.

I took three LEDs and pushed them in the holes, with the anodes, or longer pins, facing away from the center of the base, and cathodes pointing towards the center.

The top soldering job is the one referred to in the text

Then I bent them to join together for easy soldering. If you install one of the LEDs the wrong way, just enjoy the popping sound as the LEDs all burn out as you power it up. If all pins point in the correct way, however, it’s easy to join the pins in one soldered joint.

Then, add a male-male pin to the anode joint. This will be the wire to be connected to the 74HC595. Every anode joint needs a wire, so there will be 7 of them. Connect all cathode joints together with short pieces of wire as shown. Add a male-male wire to one of the cathode joints, as they are cascaded together. That pin goes into the ground rail of the breadboard.

The final look with 7 anode wires and one ground wire added

The code for one shift register

The code relies on the ShiftRegister74HC595 library. Install that and save all your hair from going grey, as it is a very neat package for all your 74HC595 projects.

The code will not do more than loop through the numbers 0 to 15, showing them in hexadecimal, ie. 0 to 9 and then a to f. The beef of the code is the use of the library. First you link to the library, then declare an object of the type:

#include <ShiftRegister74HC595.h>

// parameters: <number of shift registers> (data pin, clock pin, latch pin)

ShiftRegister74HC595<1> sr1(11, 13, 12);

From now on, the object sr1 will take your commands. The <1> tells the program to use one shift register (see below for two shift registers).

Next, declare the bytes of your digits, using a byte array:

byte num[] = {
B00111111, //0
B00000110, //1
B01011011, //2
B11001111, //3
B01100110, //4
B01101101, //5
B01111101, //6
B00000111, //7
B11111111, //8
B11101111, //9
B01011111, //a
B01111100, //b
B00111001, //c
B01011110, //d
B01111011, //e
B01110001  //f
              };

Since this is an array, you can access the byte you need by giving the index of the number you need: num[3] returns the byte for the number 2.

void loop() {
  // Cycling display 0-F
  for (int i = 0; i <= 15; i++) {
    uint8_t pinValues[] = {num[i]};
    sr1.setAll(pinValues);
    delay(1000);
    }
}

All this does is run a loop index i from 0 to 15 and uses the variable pinValues to store the byte value at that index. The command sr1.setAll turns all those pins high, which lights the required LEDs. If the soldering is done well, and you have connected the right pins to the right connectors of the 74HC595, you will enjoy the boundless joy of seeing your large scale, home made, DIY 7 segment display light up.

Adding another 74HC595 and a second digit

You may recall that the pin 9 of the 74HC595 is left unconnected above. That’s because it is used to pass data onto the next shift register, where it is inserted into the data in pin, 14.

In code, all the changes we need are in the declaration of the sr1 object, and the construction of data to pass to it. Change the number of shift registers from 1 to 2, and change the variable to have two values:

uint8_t pinValues[] = {num[i], num[j]}; 

And the complete code of two shift registers is this:

#include <ShiftRegister74HC595.h>
// parameters: <number of shift registers> (data pin, clock pin, latch pin)
ShiftRegister74HC595<2> sr1(11, 13, 12);

// Define the encoding of characters 0-f of the common-cathode 7-segment Display in bits
byte num[] = {
B00111111, //0
B00000110, //1
B01011011, //2
B11001111, //3
B01100110, //4
B01101101, //5
B01111101, //6
B00000111, //7
B11111111, //8
B11101111, //9
B01011111, //a
B01111100, //b
B00111001, //c
B01011110, //d
B01111011, //e
B01110001  //f
             
};

void setup() {
}
void loop() {
  // Cycling display 0-F
  for (int i = 0; i <= 15; i++) {
    for (int j = 0; j <= 15; j++) {
    uint8_t pinValues[] = {num[i], num[j]};
    sr1.setAll(pinValues);
    delay(1000);
    }
  }
}

To make it one display, just change the number of the shift registers to 1, and lose the loop for j.

This video shows the two digit system looping through 256 values in hexadecimal notation.

I hope you enjoyed reading this and will build some digits, then figure out how to use this for fun and profit.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.