How to Get Your HS420361K-32 4 Digit 7 Segment Display Working with an Arduino


Typically when I get new electronics components to play with, I just google the part number and lookup tutorials on how to get it working. This has been a pretty successful strategy more often than not. However, this wasn't the case when I needed to get the HS420361K-32 4 digit 7 segment display to work.

The rule of thumb for when you want to work with an electronics 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, then I knew I needed to put in quite a bit of extra effort.

So where do we start? Let's start with the 7 segment display.

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 pick me up if you need one

The cathode is the negative terminal and the anode is the 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?

Now 7 segment displays come is quite a number of combinations, you could just 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 blog.

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
Basically, at this point all I now need to know is 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.

With this background knowledge, we are now equipped with the information we need to start working with the arduino. So what do we need to have some working prototype? Well, it's best to have the following at hand:

  • 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
Next, you'd want to connect your led display pins to the arduino as outlined below:

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 below we have a pretty poor "schematic" of the circuit using Fritzing. This is my first, and possibly last, time using Fritzing.
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.


via GIPHY

References

These were some of the resources that I used in the making of this post, you could check them out for extra information.

No comments