The rule of thumb for when you want to work with an electronic component is you use its datasheet as a point of reference. The datasheet will inform you on things like what the pins do, how much voltage and current it can handle, and a whole load of extra information that should equip you with enough knowledge to get the component up and running. So when I went looking for the HS420361K-32’s datasheet and didn’t find it, I knew I needed to put in quite a bit of extra effort.
These kinds of displays can be found in calculators, watches, microwaves, almost any display that needs to portray numerical information. The convention for naming the seven segments that make up the display is as shown in the diagram above, from A to G. Lighting these segments in various combinations will enable you to display a particular number, or even some alphabetical characters.
7 segment displays come in one of two combinations: it could be a common anode connection
in which all the anodes of the constituent segments are connected together; or it could be connected in a common cathode connection
in which all the cathodes are connected together. Just a quick reminder of which side of the diode symbol is the anode and which the cathode if you need one
The cathode is the negative terminal of a diode, and the anode is its positive terminal. One way I like to remember this is we know that the diode symbol points in the direction of conventional current, therefore current moves from anode to cathode, from A to C, get it, you can remember it like AC current, yes?
7 segment displays come is quite a number of combinations, you could have a single digit 7 segment display like the one shown below
or a 4 digit 7 segment display like the one that’s the topic of this post.
One good thing about 4 digit 7 segment displays that I was happy to find out is that if they are the type that have 12 pins, then the layout is pretty much as shown below, regardless of whether it’s a common anode or common cathode type of a display
The D1-D4 are the common pins that are connected to digit 1-4 respectively.
PIN NO | SEGMENT/COMMON POINT |
---|---|
1 | E |
2 | D |
3 | . |
4 | C |
5 | G |
6 | D4 |
7 | B |
8 | D3 |
9 | D2 |
10 | F |
11 | A |
12 | D1 |
At this point, what needed to be determined was whether the HS420361K-32 was a common anode, or a common cathode kind of display. This is where a datasheet could have helped, but nonetheless, it turns out it is a common cathode kind of display. This information is of particular value if you are going to be searching for a library to use to control the display.
- A HS420361K-32 Display (doesn’t have to be this strictly)
- An Arduino (I’ll be using the Uno)
- 4 x 330Ω Resistors
- Breadboard
- Male to Male Jumper Wires
ARDUINO PIN | LED PIN | SEGMENT/COMMON POINT |
---|---|---|
2 | 12 | D1 |
3 | 11 | A |
4 | 10 | F |
5 | 9 | D2 |
6 | 8 | D3 |
7 | 7 | B |
8 | 6 | D4 |
9 | 1 | E |
10 | 2 | D |
11 | 3 | . |
12 | 4 | C |
13 | 5 | G |
And this is how it should actually look like once hooked up
The reason I chose the pin layout as outlined in the table above is because I wanted to have a clean cable layout whereby you could see the led display without cables running over it. These kinds of design considerations are pretty important 😉.
Once everything is hooked up nice and securely, the next step is the fun step, which is the code.
When this is run as it is, it should display the value of pi correct to three decimal digits.
The code itself is pretty lengthy because it has quite a number of functions for displaying various characters. I could make it into a library so that everything looks nice and clean. I don’t really want to get into the whole code situation right now, I think I’ll leave that for another day but I have tried commenting on it so that it should be relatively straight forward.
What I’m especially excited about the code is all the alphabetically characters that I managed to add into the code so you can write text to some extent.
So, that’s it, that’s how to get a common cathode 4 digit 7 segment display to work. Below is a little loop of all the characters that the code above can display, if you are interested in the code that runs the loop, you can get it from my github.
References
- YouTube video on Arduino and the 4 digit 7 segment led display [Anything Arduino] Ep 21
- Wikipedia article on the Seven-segment display
- Instructable article on Using a 4 Digit, 7 Segment Display, With Arduino
GREAT !!
THANK YOU !
Appreciate the post. First result when I Googled HS420361K-32. I can’t believe none of the ‘datasheet’s actually show a pinout!
Glad the post was of help. Wrote it because when I was first using it I too couldn’t get information on display.
Thanks for sharing.
Great help.
You’re welcome, glad to hear it was of help.
Man, thanks you for the code! Saved me a lot of time and effort.
You are welcome, glad that my post was of assistance.
Nice explanation Engineer
Thanks Benjamin 🙏🏽