One of my favorite things about working with Arduino is the LED displays and it doesn't matter if they are 7 segment or LED matrix.
They are very interesting because there is a kind of "magic" in the way they work. What you see on displays are optical illusions, possible only due to Persistence of Vision (POV)!
However, LED displays have several pins to be connected into Arduino and the best solution to reduce complexity is data multiplexing.
With this solution, LED segments are activated only for a few moments (milliseconds), but due to the high refresh rate creates the illusion of a complete image.
A prototype using LED displays takes a long time to assemble with all its components and includes many wire connections.
To simplify and speed up the process of assembling my prototypes, I developed a multipurpose LED module using simple and common electronic components.
Even though there were several LED display modules on the market, my choice was to develop a custom module that worked robustly using components like 74HC595 (shift register) and ULN2803 (drivers).
With this module, it is possible to use LED matrix with two-color LEDs in two different sizes (large and small), as well a 7-segment x 4-digit display.
Note: this module can also cascade with other modules, either in serial or parallel mode for data transfer.1. Components
PCB (Printed Circuit Board)
- 74HC595 (03 x)
- ULN2803 (02 x)
- Transistor PNP - BC327 (08 x)
- Resistor 150 Ohms (16 x)
- Resistor 470 Ohms (08 x)
- Capacitor 100 nF (03 x)
- IC Socket 16 pins (03 x)
- IC Socket 18 pins (02 x)
- Pin connector female - 6 pins (8 x)
- Pin headers 90º (01 x)
- Pin headers 180º (01 x)
- Conector Borne KRE 02 pins (02 x)
- PCB (01 x) - Manufactured
- Arduino Uno R3 / Nano / similar
- LED Display 04 Digit x 7 Segments - (Common Anode)
- LED Dot Matrix Dual Color (Green & Red) - (Common Anode)
My first prototype was built into a breadboard to test the circuit. After that I made another prototype using a universal board as shown in the pictures.
This type of board is interesting to produce a quick prototype, but it still holds a lot of wires.
It is functional, but not so elegant solution compared to a manufactured end PCB (the blue board).3. Printed Circuit Board (PCB)
- Simple and useful for prototypes.
- Easy and expandable installation.
- Able to use 2 different types of LED matrix and 4 dig x 7 seg LED display.
- The width of PCB must be the the same of LED matrix.
- Maximum length at 100 mm to minimize PCB production cost.
- Apply traditional components instead of SMD to simplify manual welding.
- The board must be modular to cascade to other boards.
- Serial or parallel output.
- Multiple boards only controlled by one Arduino.
- Only 3 data wires for Arduino connection.
- 5V external power connection.
- Ensure greater electrical robustness by applying transistors and drivers (ULN2803) to control the LEDs.
For programming, you should keep in mind some important concepts about hardware design and the 74HC595 shift register. The main function of the 74HC595 is to turn 8-Bit Serial-In into 8 Parallel-Out Shift. All serial data enters the pin 14 and in each clock signal the bits go to the respective parallel output pins (Qa to Qh).
If you continue to send more data, the bits will be moved one by one to Pin # 9 (Qh ') as serial output again and because of this feature you can put other cascading chips together.
In this project, there are three ICs of 74HC595. The first ans second IC control the columns (with POSITIVE logic) and the third IC controls the lines (with NEGATIVE logic due to the operation of the PNP transistors).
Positive logic means that you must send a HIGH (+ 5V) level signal from Arduino and negative logic means that you must send a LOW (0V) level signal.
- The first is for the cathode outputs of red (8 x) LEDs >> RED COLUMN (1 to 8).
- The second is for the output of the Green LED cathodes (8 x) >> GREEN COLUMN (1 to 8).
- The last one is for the anode outputs of all the LEDs (08 x Red & Green) >> ROWS (1 to 8).
For example, to connect only the green LEDs in column 1 and row 1, the following serial data string must be sent:
1º) Rows ~10000000 (only the first line is set to on) - The symbol ~ is to invert all bits from 1 to 0 and vice-versa.
2º) Green Column 10000000 (only the first column of Green LED is on)
3º) Red Column 00000000 (all Red LEDs columns are off)
shiftOut(dataPin, clockPin, LSBFIRST, ~B10000000); //Negative logic for the lines shiftOut(dataPin, clockPin, LSBFIRST, B10000000); //Positive logic for the Green columns shiftOut(dataPin, clockPin, LSBFIRST, B00000000); //Positive logic for the Red columns
You can also combine the two LEDs (Green & Red) to produce YELLOW color as follows:
shiftOut(dataPin, clockPin, LSBFIRST, ~B10000000); shiftOut(dataPin, clockPin, LSBFIRST, B10000000); shiftOut(dataPin, clockPin, LSBFIRST, B10000000);
7 Segments display
For these type of displays the sequence is the same, but do not need the Green LEDs.
1º) DIGIT (1 to 4 from left to right)
~10000000 (set digit #1)
~01000000 (set digit #2)
~00100000 (set digit #3)
~00010000 (set digit #4)
2º) NOT USED
00000000 (all bits set to zero)
3º) SEGMENTS (A to F and DP - check your display datasheet)
10000000 (set segment A)
01000000 (set segment B)
00100000 (set segment C)
00010000 (set segment D)
00001000 (set segment E)
00000100 (set segment F)
00000010 (set segment G)
00000001 (set DP)
Arduino example to set Display #2 with the number 3:
shiftOut(dataPin, clockPin, LSBFIRST, ~B01000000); //Set DISPLAY 2 (Negative logic) shiftOut(dataPin, clockPin, LSBFIRST, 0); //Set data to zero (not used) shiftOut(dataPin, clockPin, LSBFIRST, B11110010); //Set segments A,B,C,D,G)
Here are two programs as examples of functionality of the Display Module.
1) Countdown display (from 999.9 seconds to zero)
2) Dot Matrix (Digits 0 to 9 & Alphabet A to Z)
3) Digital Clock RTC in LED Display of 4 Digits and 7 Segments