LED Displays with Arduino - 7-Segment & Dot-Matrix

Rek XIX
40 followers
9 Video Views·Oct 31, 2022
LED Displays with Arduino - 7-Segment & Dot-Matrix
Today in the workshop we're working with LED displays.
We'll see how to use an Arduino with both 7-segment and dot-matrix displays in a variety of configurations.
We'll also check out some great display libraries to simplify our coding tasks.
We're emitting some light on the matter today, so welcome to the workshop.
Well hello and welcome to the workshop and today we're going to be working with LED displays.
Now LED displays were arguably the first type of solid-state display device.
And in fact it's because of LED displays and their popularity in the mid-1970s
that we started seeing the word digital used with consumer electronics.
Things like digital clocks, digital watches, digital calculators, all used 7-segment LED displays.
Now despite their age, LED displays can still be a very good choice for a number of applications.
They aren't a good choice for a battery-powered device because they use a lot of current.
But if you're building a device that needs an indoor display that's visible in all kinds of light conditions,
from all sorts of different angles, if you want to be able to choose from a variety of colors and sizes,
and if you're looking for an inexpensive display, then LED displays are a good choice.
We're going to be working with both the 7-segment and the dot-matrix type of LED displays today.
But before we do, let's learn a little bit more about these displays.
In 1962, General Electric developed the first light-emitting diode.
In 1969, Hewlett-Packard created a replacement for the Nixie tube using light-emitting diodes.
Nixie tubes were display tubes that used filaments to display numbers.
LEDs became very popular in the 1970s thanks to the advent of the 7-segment display.
Original LED displays were all red, with green displays following soon.
LED displays have a number of advantages.
They're very low-cost, they're extremely reliable, they have a very long lifespan,
and they're very durable and can easily be made weatherproof.
However, LED displays have a much higher current consumption than other display technologies.
They're also limited to the number of characters that they can display.
In order to view LED displays best, you usually require a filter or bezel in front of the display in order to accent the characters.
Today we'll be working with two different types of LED displays, the 7-segment display and the dot-matrix display.
We'll begin with the 7-segment display.
The 7-segment figure representation of numbers has been around for quite some time.
In 1903, it was used for telegraphy, with telegraph signals transmitting the individual segments of the display.
By 1910, there were 7-segment displays in operation that used incandescent bulbs.
But it wasn't until the 1970s that 7-segment displays became commonplace, thanks to the use of LEDs.
7-segment displays consist of seven individual LEDs, and they can be wired in two configurations.
One configuration is common cathode, where all of the LED cathodes are tied together.
In this configuration, the cathodes are all grounded, and applying a positive voltage to the individual segment inputs will light the LED.
The common anode configuration is the reverse, where all of the anodes are tied together and tied to the voltage source.
Applying a ground-level signal to the inputs will light the LEDs.
No matter which configuration you choose, you're going to require dropping resistors.
These will limit the amount of current and voltage delivered to each LED.
There are two different ways to hook up dropping resistors to a 7-segment display.
The most common and best performing method is to use an individual resistor for each of the segments in the display.
For a 5-volt power supply, these resistors can be somewhere between 220 and 470 ohms.
Another method of connecting a dropping resistor is to use a single dropping resistor on the common side.
This method, of course, has an advantage in that it only requires one resistor,
but its disadvantage is that the display brightness will vary depending on the character it displays,
because the current is being divided up by the number of LEDs activated.
So, for example, a number 1 will appear much brighter than a number 8.
Nonetheless, if you wish to use this method, for a 5-volt supply, you can choose a resistor with a value between 820 and 1.5k.
In order to display characters, we illuminate the individual elements of the display.
We can build up a truth table that indicates which elements are lit for each character,
and we can display every character numerically from 0 to 9, plus the first 6 letters of the alphabet for use in hexadecimal displays.
LED displays have excellent visibility in the dark.
The newest generation of LED displays are also visible outdoors in broad daylight.
Unlike other display technologies, LEDs have very good visibility at wide angles.
These displays are inexpensive and are available in multiple sizes and with different color selections.
There are so many choices of LED displays that you're sure to find one that's perfect for your project.
So let's start working with LED displays.
So here are a number of 7-segment LED displays, many of which we are going to be working with a little later on today in this video.
Now this first one over here is an individual display, and like all of the displays, it's got the 7-segment character, plus it's got a decimal point.
And if I flip this one over, you'll notice a number of leads, there are actually 10 of them.
And the 10 leads go out, 8 of them go out to the LEDs, the 7 segments and the decimal point, and the other 2 are the common ones.
And in this case, this is a common cathode LED display, but the wiring on a common anode display would be just the same.
Now here's one that has 2 elements in it, and you might expect double the number of wires, but you don't get double the number of wires.
And I'll show you in a little bit how this is wired, because the same goes for this 3-element and this 4-element display.
The 4-element display doesn't seem to have many more wires than the 2-element display.
So I'll show you what the wiring is inside these displays in a bit, and also how we can use an Arduino to drive one of them.
And this last one, as you can see, actually has 8 LED displays on it, and this one only has 5 connections for all 8 LEDs.
And again, this is a different way of connecting than connecting directly to the individual elements, and we'll be showing you that as well later in the video.
So let's go and start working with our 7-segment LED displays.
So let's begin our experiments with LED displays using the simplest LED display of them all, the standard 7-segment LED display.
Now, I'll be using a common cathode device for this and for all of my experiments, and they are the most common type, but you could rewire everything for a common anode device if you wanted to.
However, I'd suggest that you try to obtain a common cathode one, as it'll be a lot easier.
So let's take a look at what it takes to drive a 7-segment display with an Arduino Uno.
In this experiment, we're going to connect a single 7-segment display up to an Arduino.
Now, this is the pinout of a standard 7-segment LED display, and most LED displays follow this pinout, but you could check the spec sheets in your display to make sure.
Note that this pinout is equally valid for both common anode and common cathode devices, and we'll be using a common cathode device in our experiments.
In addition to the 7-segment LED, you're also going to require an Arduino Uno and 8 dropping resistors, 220 or 330 ohms.
Now, I used a resistor array pack, which contains 8 resistors in a 16-pin DIP packet, because I find it a lot easier to wire with this, but you can also use individual resistors if you wish.
We'll begin by connecting pin 6 of our Arduino through the dropping resistor to segment A of the LED, that's pin 7 on our LED.
Pin 5 of the Arduino will be connected to segment B, which is pin 6.
Pin 2 of the Arduino will go through the dropping resistor and then connect to segment C, which is pin 4.
Pin 3 of the Arduino will connect through the dropping resistor to segment D, which is on pin 2.
Arduino pin 4 will be connected through its dropping resistor to segment E, on pin 1.
Pin 7 on the Arduino will be connected through its resistor to segment F, which is on pin 9.
Arduino pin 8 will be connected to segment D, which is on pin 10.
And we'll connect pin 9 of our Arduino through its dropping resistor to the decimal point segment, which is on pin 5 of the LED display.
And because this is a common anode LED display, we'll connect the ground of the Arduino to the common pin on the display.
And this completes our wiring. Now let's take a look at some code we can use to run our LED display.
Now there are a number of different methods to drive a 7-segment LED display that's been connected directly to the I-O ports in an Arduino.
And you can do it manually, because after all, all you're doing is you're turning on and off LEDs.
So you create arrays, for example, which is a very common method of doing it, and have an array for every single number.
And the array would have all the different elements of the 7-segment LED and would indicate whether they're either high or whether they're low.
Another way of doing it is to use a library, and I find that to be a lot easier.
And so we are going to be using a library called SEVSEG, and it's made exactly for doing this.
So it's S-E-V-S-E-G, and you can see it over here by Dean Reading, and we're going to install that.
Okay, so now we've got that library installed, we can go and take a look at a sketch I've created in order to use the 7-SEG library.
And we're going to start off by including that library, and then we're going to create an object which is going to represent our 7-segment display, and we're just going to call it SEVSEG.
Then we're going to define a number of parameters for our display.
Now the first one is the number of digits in the display.
The 7-SEG library can be used with LED displays that have more than one digit, like some of the ones I showed you a little bit earlier.
And in fact we're going to be using it with the 4-digit display in a moment.
But right now we're using a single digit, so it's just a 1 over here.
Now the display select pin is not relevant when you're using only one single display.
But when you're using multiple displays, it tells you which pins you're using to select the various different displays in the unit.
So if it's a 4-digit display, for example, there would be 4 entries over here.
But for a single digit one, there's no entry.
Then the display segment pins are over here, and these are in the order ABCDEFG and then the decimal point.
And so you just define the pins that you're using on your Arduino to connect the display.
So if you want to connect it differently, you can just change this string over here.
You need to also indicate whether you're using dropping resistors or not, because this can actually try to use PWM to simulate the effect if you're not using them.
And then the display type, and in our case it is a common cathode display, but of course you could also use a common anode display.
And then it's very easy to use and set up.
You set up your display object, you do a begin, and you pass all those different parameters that we just went over.
And then you can set your display brightness, and this can be any value from 0 to 100.
And then in my loop, I'm just going to set a number to display.
So we're just using the set number property, and we are giving it the number to display.
So I'm going to give it the number 3 right now, and we're going to refresh the display and then do it over.
So we should be displaying a number 3.
So let's just load that up to my Arduino right now.
And as you can see, we've got a number 3 on the Arduino right now.
Now let's go back into the code over here and change that number 3 to a different number.
Let's make it a 6, and we'll upload that.
And there we have a number 6.
So as you can see, the 7-seg library makes it very easy to print to an LED display, to a 7-segment display that you've got connected directly to your Arduino.
Now here's another bit of code that just expands upon our previous sketch.
And what we're going to do is we're going to create a counter.
And we're going to be using the 7-seg library again.
So we're going to start off exactly the same way we did before by including the library.
Creating an object.
Defining all the parameters for our display, which are identical to what they were in the previous sketch.
Then in setup, we're going to start our display the same way that we did before, and we'll set the brightness.
And then in the loop, where we're going to do things a bit differently.
And we're going to set up a counter here.
So we're going to make an integer i, whose value is going to be from 0 to less than 10, which in other words is 9.
We're going to increment that.
And as we cycle through it, we're going to use the set number property on 7-seg to set the number that we display on the LED display.
We'll wait for a second, refresh the display, and go and get the next number.
So this should just cause the display to count from 0 to 9, and then repeat.
So let's load that up to the Arduino, and take a look at it in action.
And so here we have our counting demonstration, and as you can plainly see, it is counting from 0 all the way up to 9, and then cycling back on itself.
And it seems to work pretty well, and the display is very readable.
Now if all you require is one 7-segment display, and you don't need other I.O. ports or anything else,
then this is actually quite a viable way of driving an LED display with an Arduino.
Now earlier in the video, I showed you a number of different LED displays, including some 2-element, 3-element, and 4-element display devices.
And I also showed you that on the back of them, they didn't quite have as many pins as you might expect for so many display elements.
And the reason is, these are multiplex displays.
And so I want to bring out the 4-element display right now, show you how it works, show you how we can hook it up to the Arduino, and write some code for it.
So let's go and do that.
In this experiment, we'll be using a 7-segment, 4-element LED display, although the principles also apply to the 2- and 3-element displays as well.
This display has four independent 7-segment LEDs.
Now I'm illustrating common cathode devices, but common anode devices exist as well.
The four LEDs are connected as shown here, with all of the segments connected together.
The common lead for each of the LEDs is brought out to a connection for digit 1, digit 2, digit 3, and digit 4.
Now here's the pinout on our display module.
As always, I would check your spec sheets for your display module to make certain that it's identical.
In addition to the 4-element display module, we'll also require an Arduino Uno and four 1K resistors.
Instead of using dropping resistors on each of the elements, we're going to be putting our dropping resistors on the display select lines.
So these need to be 1K resistors.
We'll begin by connecting Arduino pin 9 to display pin A.
Arduino pin 2 will go to display pin B.
Arduino pin 3 to display pin C.
Pin 5 of the Arduino to the display's D-segment.
Arduino pin 6 to display pin E.
Pin 8 to display pin F.
And pin 7 to display pin G.
We'll be connecting Arduino pin 4 to the decimal point pin on our display.
Arduino pin 13 will go to digit select 1 pin.
Pin 12 to digit 2.
Pin 11 to digit 3.
And pin 10 to digit 4.
And this completes our wiring.
Now let's take a look at some libraries and code we can use with this 4-element display.
Now here's a simple sketch that we can use just to display a 4-digit number up on our display.
And once again, we're going to be making use of the 7SAG library.
Now, you'll find this sketch is almost identical to the one that we used to display an individual digit on the single display.
Most of the changes are just in the top of the sketch.
So we begin by doing the same thing, including the 7SAG library, and creating an object for the 7-segment display.
Now here's where some of the changes are.
First of all, the number of digits we have is now 4 instead of 1.
And the display select pins. Now this array actually has values, and it's got 4 values in it.
And those are the 4 pins that we've used for the display select pins on our display.
And so, of course, you could wire things differently and just change these numbers around.
And then we once again have the segment pins.
So these are the pins we've used for the 8 different display segments.
We've used dropping resistors, and it is a common cathode display.
Now the setup is identical to what we did before.
We just do a begin, we set the brightness, and then we have a loop over here.
And we did the exact same thing that we did in our first sketch.
We just did set number, only now it's a 4-digit number.
So I'm just going to pass the number 1, 2, 3, 4 up to our display.
And then we'll refresh the display and do everything all over again.
So it's a very simple sketch.
Let's load it up to the Arduino and take a look at the results.
So here's a demonstration of our 4-digit LED display being driven by the Arduino directly.
And it seems to work pretty well.
You can see our 4-digit number on the display quite clearly.
Now the display is not as bright as it was when we were using the single digit.
And that is because of the dropping resistors we have over here of 1K.
And you have to remember the dropping resistors are on the display select lines.
And so the current is being divided between all of the different LED segments and that single dropping resistor.
Now as a result, this does have a bit of an effect that you can't really see on the camera.
Because I think the camera is compensating for it.
But I can see it myself right now.
And that's that the number 1 is quite a bit brighter than the other numbers over here.
And that's because of course the number 1 only requires lighting of 2 different segments.
And so it's got the current all being divided between these 2 segments.
Where something like a number 3 uses 5 segments.
And that same amount of current is being divided 5 ways.
So that's one of the consequences of using the resistors on the display select line.
As opposed to using 7 or 8 if you include the decimal point resistors on the lines to the individual segments.
But otherwise it's a reasonable compromise.
The display is reasonably bright but not as bright as the individual display was.
But it's certainly quite usable.
Now of course we've used pretty well every digital I.O. pin on this Arduino up.
So if you have a project that just needs a display and that doesn't need too many I.O. ports.
You can always use the analog ports as digital ports.
Or you can use them indeed as analog ports if that's what your project requires.
Something like let's say a thermometer or something.
This would be a pretty viable arrangement for hooking up a 4 segment LED display to an Arduino.
Now I'm going to run another demonstration on the 4 digit LED display.
And for that I'm going to use one of the example sketches that comes with the 7 seg library.
And this is the 7 seg counter.
And you can get to it by going into examples.
And then do examples from custom libraries.
Go into 7 seg and you'll see 7 seg counter over here.
Now I've got it open on this side beside the sketch that we ran earlier.
Just because I'm going to need to make some modifications to this sketch.
And the reason is they use different pins and some different parameters for their display.
So it's quite easy to do.
The number of digits is correct.
But the digit pins are different.
So I'm going to go into my original and get the digit pins over there.
And copy them over here.
And the same deal with the segment pins.
They are different as well.
So I'll take my segment pins and modify the example sketch to use those pins.
And resistors on segment is actually going to be true.
And it's a common cathode display that I have here.
Okay, and so let's just make this big right now.
Because we don't need the other one.
And so this is a display that's just going to go and do a counter.
And so it starts off pretty well the same way that we started off our other display.
They do everything in the setup instead of at the beginning.
But it's the same deal.
And then we go into a loop over here.
And we're going to do a counter.
And we're going to count through our counter.
And display that onto the display using the set number.
So it's pretty well the same type of thing that we did earlier with the individual display.
So let's just load that up now to our Arduino.
And take a look at it in action.
And so here's our counter in action.
And as you can see I've got over to 700 right now.
And it's just going to continually account until we reach 9999.
And then it's going to turn over.
You'll have to trust me on that because it's going to take a while to watch it do that.
But just another example of how easy it is to use a library to write to one of these four digit LED displays.
And so once again, if you don't mind using up all of the different IO ports,
this is a pretty cool display option for an Arduino.
Now multiplexing the wires in a display does indeed cut down on the number of connections you need to use
for a four digit unit.
But it still is a lot of connections.
If you look at our last example, we used pretty well every digital IO connection on the Arduino Uno
in order to drive four displays.
Now what if we wanted to drive 8 or 16 or something?
We're going to run out of IO ports pretty quickly.
Well there's another way of doing this.
And that's by using a chip that converts serial data into LED data.
And there's a chip called the MAX7219 that does this particularly well.
It can be used with both 7-segment and dot matrix displays.
So what we're going to do right now is take a 7-segment display that has 8 elements
and only requires 5 connections, and that includes power and ground.
So let's go and take a look at how this works.
Our 8-element display is based around a chip made by Maxim Semiconductors called the MAX7219.
The MAX7219 accepts serial data and can drive up to 64 LEDs.
Inputs to the MAX7219 include data in, load, which is also called CS or chip select, and a clock pin.
The MAX7219 also provides a data out pin so that you can cascade devices.
And it provides outputs to drive 64 LEDs on an 8x8 matrix.
This can be used for dot matrix LED displays.
And it can also be used to drive 8 7-segment displays, including decimal points.
And that's what we'll be doing today.
The only other thing that we're going to need in addition to our display is an Arduino Uno.
We'll connect the 5-volt output of the Arduino to the VCC of our display.
If you wish, you could also use a separate power supply.
And if you intend to cascade displays, you should use a separate power supply.
We'll connect the Arduino's ground to the display's ground.
Pin 12 of the Arduino will be connected to the data in or DIN pin on our display.
Pin 11 of the Arduino will be connected to the CS pin on the display.
This may also be labeled as load on some models of displays.
And pin 10 of the Arduino will be connected to the clock pin on our display.
And this completes our wiring.
Now in order to make use of our 8 LED display, we are of course going to be using a library.
And there are a number of different libraries to choose from.
Because the MAX7219 chip that is driving our display is an extremely common display controller.
And so let's go and install a library right now.
Let's go into manage libraries.
And do MAX7219.
And you'll see there are a number of different ones.
Now we're going to come back to this because we're going to install another one in a while.
But the first one I'm going to use, which I've already installed, is called MAX7219 by Jonathan Evans.
It's just called MAX7219.
So install that library and then go into the examples and choose the demo example.
And that's what we're going to look at right now.
And the demo example is just going to print some text over to our display.
And do a few things like scrolling to illustrate the properties of the library.
So it's going to start by including the library and creating an object.
And in the setup, we're just going to set up a serial monitor.
And we're going to start off our new object.
And everything is done in the loop.
And so we define a couple of strings, a character, and an integer over here.
And we go on to write our demo.
So it's going to write a demo over here.
I guess it's supposed to be temperature in Fahrenheit.
It's going to right justify and left justify the text.
And so that's what this property over here is right or left justified.
It's going to show a counter over here with some decimals.
And it's going to display that.
And again, you can justify the text over here with a second parameter every time you do a display text.
So you basically do a display text every time that you want to write over to the display.
It's going to go through a counter.
It's going to go through a number of characters.
And it's going to position the characters, move them around.
It's going to count from the left, count from the right, just a number of demo functions.
And so you can go through all these different examples and see how you can use this library.
Now I find this to be a good library.
The only restriction though is first of all, there don't seem to be any way that you can specify different connections to your display.
So you have to connect it up exactly this way.
And another thing is if you're going to use more than one of these eight character displays,
there doesn't seem to be any way to specify which of the ones that you're using.
So if your needs are fairly simple, this is a good library to use.
Let's load this demo sketch up and take a look at it on our display.
And so here's our demonstration text running on the display.
And as you can see, it's displaying a number of random characters.
It's going back and forth.
It's scrolling between all of the different digits.
A little while ago it was doing a count.
It's quite an involved display.
I think it's just starting again now, giving those temperatures both left and right aligned.
Now it's going through its counter.
It starts off kind of slow with a decimal point and then it goes faster.
So as you can see, it's a pretty versatile library.
And it makes it very easy to work with these eight character displays,
providing that you only want to work with one eight character display
and that you can connect it the way that I have shown you in the hookup diagram.
Now the library that we just looked at is actually suitable for most purposes.
But if you want to cascade displays, you're going to need to find another one.
And as we saw earlier, there are a number of different libraries for the MAX7219.
Now one of them is called LED Control.
And you can go into your library manager and just look for it.
It's this one over here, LED Control.
It's kind of the classic library for controlling these devices.
And so you might want to check it out.
And we're going to check out one of the example sketches from it right now.
So I've already installed the library.
I've opened up the LC demo cascaded devices example that they give us.
Now we're going to have to make a modification to this.
It doesn't seem to need to know how many devices we have.
It's going to detect them.
And you can add up to eight devices cascaded with this.
But we do need to change the pinouts because they're different than the ones that we used.
And so we're going to have to put in 12, 10, 11, and 2.
So the 12 is right.
We're going to switch to 10 and the 11.
And we used pin 2 over here.
And so once we do that, we should be able to load this up to our board.
And take a look at it.
Now what this is going to basically do is it's just going to go through the device.
And it's going to go through every single segment on each one.
One by one and light them up.
And so it's going to take forever to run the whole thing.
But it's both a good way of testing your devices.
And also to see how we can work with cascaded devices.
So load it up and let's check it out.
So here's our demonstration.
And you can see what it's doing.
It's just going through both displays.
And it's lighting segment by segment of each display element.
And it's alternating between the two cascaded displays.
And so you could cascade more displays.
It'll actually accept up to eight displays.
And it will continue to do this.
So this is both a good demonstration of how to cascade displays.
And also it's a great test to make certain that every one of the segments on all of your displays is working.
Well up until this point we've been using 7-segment LED displays.
And 7-segment LED displays are useful when all you need to do is display numerical data.
But if you need to display texture, if you need to display symbols, you can't really do it with a 7-segment display.
There are a couple of letters you can do on a 7-segment display.
But you certainly can't do the entire alphabet.
There's another type of LED display.
And that's called a dot matrix display.
And it consists of a matrix of LEDs instead of individual segments.
And by using one of these displays you can display just about anything.
You can display alphabet characters.
You can display numbers.
You can display special symbols.
So let's go and take a look at how these displays work.
And then we'll connect some up to our Arduino.
So I've got some 8x8 LED matrix displays over here.
And this is what we're going to be working with today.
And I've got two of them over here.
There are two groups of four.
And each of them is mounted onto a printed circuit board.
They're actually cascaded.
And so you've got four of the same circuit.
And I've pulled one of them off to show you the integrated circuit that's underneath here.
Now on the bottom here you'll just see the connections.
And the connections are basically just a row and column connections for the display.
Now these are green displays but you can get them in blue.
You can get them in red.
And you can also get multicolored displays as well where certain rows are in certain colors.
So they're quite versatile.
Another thing you can do with these is you can cascade them.
So you can put two of them back to back and make a very very long display.
So it's quite versatile.
So let's go and see what it takes to hook one of these up to an Arduino.
And then we'll run some code to make some very interesting displays on our 8x8 matrix displays.
An LED matrix display is much more versatile than a 7-segment display.
As not only can it display numbers, it can display letters in both upper and lower case.
Plus a number of special symbols.
These displays consist of 64 LEDs arranged on an 8x8 matrix.
The LEDs can be addressed by row and column.
This is a perfect match for the MAX7219.
And so many of these displays are available with the MAX7219.
The display I'll be using today consists of four 8x8 LED matrices.
Each matrix has its own MAX7219 and they are cascaded as shown here.
You can also use individual displays if you wish.
In addition to the four matrix displays you're going to require an Arduino Uno.
And you're going to require an external 5V power supply for your display as well.
The 5V output of the Arduino's internal regulator does not have sufficient current for these displays.
We'll connect the VCC on our display to the positive side of our 5V power supply.
We'll connect the ground of our display to the negative side of our 5V power supply.
We'll also make a connection to the Arduino's ground here.
We'll connect Arduino pin 11 to the DIN pin or data in pin on our display.
Arduino pin 3 will go to the CS pin on our display.
On some displays this may be labeled as load.
And finally pin 13 of the Arduino will be connected to the display's clock input.
And this completes our wiring.
Now let's go take a look at a couple of libraries that we can use to drive our display.
Now as you probably guessed when we're using a matrix LED display we're going to be making use of a library.
And there's an excellent library called the Parola library that can be used to drive these displays.
And you can drive multiple displays in order to make some very, very intriguing demonstrations.
They've got all sorts of demo code.
You can do text scrolling.
You can do animations.
They've got all kinds of examples you can use to make a very fancy display.
So let's install Parola onto our Arduino IDE.
Now I've already got my library manager open.
And you're going to search for MAX72XX.
And you'll see it down here, MD Parola.
And we're going to go and install that.
And when we hit install it's going to tell us that we're going to have some dependency libraries as well.
So we're going to say install all.
And our libraries are installed.
Now there are a number of example sketches that come with this library.
And I urge you to go into it and give it a try with your displays.
Some of them work very well if you have multiple displays.
Such as if you have an 8 unit or a 12 unit instead of the 4 unit that I'm using.
But all of them are really educational and you'll be able to find all sorts of things.
We're going to do some very basic ones right now.
So this is our first basic demo.
And we're going to start off by including the libraries.
Including the SPI bus library.
Which is included with your Arduino IDE.
And that's because we're making use of the SPI bus for this display.
The next thing we're going to do is set the display type.
And there are two different types of displays that it supports.
And this is the one that I'm using.
It's a pretty standard one.
So if your display looks something like my display, that's the one you want to choose.
Otherwise there's another one over here that you can try.
Now we want to know what chip select pin we're using.
We know we're using the SPI bus.
So the other pins have been defined.
But we're going to define that.
And so we define that as 10.
And we also define the number of devices.
And I have 4 of these displays on my board.
So my devices is set to 4 over here.
Then we're going to create a display object that we're just calling my display.
We're going to pass those parameters back to it.
And in this setup we're going to begin that object.
We're going to set the intensity of the display.
And this can go from 0 to 15.
And you can play with this.
At 15 it's quite bright.
So you might want to set it up or down depending on your preferences.
I've got mine set to 5.
And then we'll clear the display.
And in the loop we're just going to demonstrate a few of the different functions that the Parola library provides.
And so we're going to do the text alignment functions.
We're going to try aligned left.
We're going to try it with center alignment.
And we're going to set the alignment right.
Then we're going to do an inverted display.
And then we're going to set the display back to normal.
And in all cases we're going to do a my display print.
And we're going to tell it what to print on the display.
Because the library makes it that easy.
Each one of these is going to have a 2 second delay.
And then we're going to go to the top and do it all over again.
So we're just going to get some text moving back and forth in our display.
So let's load this up to our Arduino and take a look at it.
So here's my demonstration of the Matrix LED display.
And you can see I've got my Arduino here of course driving the Matrix display.
And here is the separate power supply that I'm using.
And this is a power supply that I constructed during a previous episode of the DroneBot Workshop.
And so if you want to build something like this you can go and check out that video.
Now one of the reasons I use this power supply instead of the 5 volt bent supply that I have.
Is because I've got the meter on the front here.
And it can tell me how much current I'm consuming.
And it does of course tend to fluctuate with how many LEDs are on.
I think when we get the invert over here it's the highest.
It was a little over 250 milliamps or a quarter of an ampere.
And it seems to hover at about 125 or so milliamperes.
But it fluctuates quite a bit of course with the number of LEDs on.
So you do need to have a bit of current in order to drive these displays.
But they're very bright displays that can be seen from a long distance.
So it's actually pretty efficient when you consider the performance you're getting out of the display.
Well I just couldn't resist it.
I had to connect the second Matrix display board up to the first one.
To extend it to 8 displays and scroll my Welcome to the Workshop across it.
And I think it looks much better with all these extra displays.
Now I only had to make some minor code changes.
If you go into the code here.
First of all with the max devices I changed that from 4 to 8.
Because I have another board with 4 more devices on it.
And then a couple of things just for personal preference.
I bumped the brightness up a little bit.
Although to be honest I didn't notice a huge difference.
That used to be a 5 and now it's a 9.
And on the scrolling speed I set it to go a little bit faster.
That was set to 100.
I set it down to 70.
But you can see the results right now quite readable.
In fact I think it's a beautiful display over here.
I might consider putting it into a frame or something.
And mounting it right at the very back of my workbench or something.
So that I can display Welcome to the Workshop all the time on my Matrix LED displays.
Now the Parola library comes with a number of different examples you can use on your display.
And I'm running one right now which is supposed to be a Pac-Man emulation.
I think if you look at the display for a little while it's just starting.
There we have the little Pac-Man and they're trying to eat those little things.
Now if you want to get at this or any of the other ones.
Just go down into your examples.
And you'll see two sets.
You'll see the Max 72XX and the MD Parola examples.
And this was in the Max 72XX.
So I took this one out the Pac-Man.
And the only thing I had to do to get it to run was on this line over here.
They had that set to 12 devices.
And I'm using 8 devices.
And those would be the 8 individual displays that are on my two modules that I've cascaded over here.
So you could pretty well spend all day playing with some of these examples.
They've got some excellent examples of how you can use these displays with the Parola library.
Okay, well this brings us to the end of our look at LED displays.
I certainly hope that you enjoyed it.
And if you're trying to hook up LED displays to a microcontroller project of your own.
Then I certainly hope that you found it useful.
Now if you want some more information about LED displays.
Or if you want to grab the code I used today.
Just head over to the DroneBotWorkshop.com website.
Where you will find an article that accompanies this video.
And there's a link right below the video to that article.
While you're on the website.
Please consider signing up for my newsletter.
No, it's not a sales letter.
It's just my way of letting you know what goes on here at the workshop.
And if you want to discuss this further.
The best place to do this of course is on the DroneBot Workshop forums.
Where we've got a bunch of like-minded individuals.
Who work with electronics and computers.
And love to discuss these things.
And it's free to join the forum as well.
And finally, if you haven't yet.
Please subscribe to the YouTube channel.
All you need to do is hit that subscribe button.
And then click the bell notification.
And as long as you've enabled notifications.
You'll be notified every time that I make a new video.
So until we meet the next time.
Please take care of yourself.
Please stay safe.
And I'll see you again very soon here in the DroneBot Workshop.
Goodbye for now.
