hi welcome to an Arduino step-by-step course by Robojax
in this lecture we are going to learn how we can use the two digit led display with Arduino
which is based on 74 hc 595 shift register this is very simple way to display two digits in my
application you need to display some numbers let's get started with this this is the first
time that we see a module is available with two digit display with simple connectivity
for Arduino finally this is based on sun 74 hd 595 shift register and two digits have been arranged
to end the module something like this when you buy it there will be no pins attached to it
simple there are two surface mount devices all the LEDs have been arranged with the
bias with the resistor so you don't have to worry about the resistor you all the pins label here
and as you can see you can cascade it also if you have other digits attached to this but for
now this two will be enough because we have four digits and eight digits display already available
this two digit has its own application in many cases you will need it to just display some
between zero to 99 say about the display if it is common cathode or common anode because it has
already been arranged and the power supplied it works with 5 volts and you need to connect three
pins that is required for the 74 hc ht595 data clock and latch which changes the state of the
movement of data to move from one digit to the other one the digits are here 0.5 inch
the length of the module is 1.5 inch or 38.1 millimeters the width is 25.8 millimeters
or 1.01 inch the depth is 0.48 inch or 12.2 millimeters so the pins have been labeled
vcc ground sdi and sclk which is clock and then load this is the input they put also an
arrow and also p1 and this arrow shows you can continue the other way for example if
this was your first one and if you want to connect the next one you can wire them here
the code that I’m providing will work only with two digits in the future I might update the code
so it can work with multiple digits but there is no need for it as we already have four digit
display which I have separate video lecture on those the link will be below this video
now let me explain the wiring this pin is connected to five volts of Arduino here at
this point gray is a ground it has been connected to this pin of Arduino we have data clock and
load pin and I’ve arranged them accordingly if data is a white one connected to the seven
clock is connected to six and then load is connected to five
let me explain the code I’ve taken the code from this web address it has a lot of issues and I’ve
cleaned it up and made it easy to be used this is the library you need to download the zip file
I’ve also fixed that Arduino was not accepting it I made some modifications so it can work once
you downloaded the zip file you can go to sketch include library and add zip library I prefer this
method because I know what I’m doing and where it is being saved rather than the dock my document so
it's saved in my own folder here let's say this is a zip file just click open and it
will be done and this is the code that will work the code example that is with it might not work
I’ve modified this for this purpose we are defining sdi pin pen seven s clock pin six
load pin five digits two for for for now it works only with two digits but in the future
it might you might be able to add cascade many of these and then we are creating an instance of the
this class and we call it sr and we pass all these four parameters here to this do not changes
change these numbers if you don't have those pins available except the two
and these are still these three and four are not available but I’ve just left them from the
original code this array had some issue with digit 6 and digit 9 which was which was not
shown properly these are each segment of the seven segment display for example for
zero you need to turn and this is a b c d e f and g and this is the last pin or h it goes clockwise
from a to f and then g and then it goes to d p for zero everything will be turned on except this pin
so that is this one this is a b c d e f and then this is g
because this is common anode you need to send zero to turn them on
for all other digits inside the setup we don't do anything inside the loop in order to display
a number let's say you want to display 18 just I’ve written this function to make it easy
show number and 18 it keeps it two seconds waiting and then I said let me have fun from
0 to 99 this is a for loop and we put show number the same way as this except this time I is getting
one two three and every time I changes this prints it uh within 100 milliseconds it prints again 2
3 up to 99 and then I give it two seconds this time I start from 99 up to 0 and decrementing
here it was incrementing going from 0 to 99 this goes from 99 to 0 and printing it and
then give it two seconds and it continuously doing the same thing so for your application
you just use this and put your number between 0 to 99 now show number is a function that I’ve written
here show number and the number or a digit that you pass will be here and it will be called num
and this is a modulus method you divide it by 10 to get the last digit and we call it digit 2
and here this is getting the digit 1 from those two num divided by 10 and then modulus 10 modulus
mean remainder and the remainder of this will be the first digit and here we are number to print
this is a value and we get one digit and two digit from the array so digit one comes here and
it goes inside the digits array this array that is holding let's say if it was 2 it will pick this up
and store it as an array this area will have two values first value second value and it goes
to this source and then set all decimal print which is taken care of by library
to display a decimal point on a digit if you look here this last bit is to keep this off one min off
all these ones to turn it on change it to zero if I upload the code you
will see that whenever it is two you will see that it will display the small point
two your side and then two again two here
every time it is two you see that it shows the decimal point
and here is a close-up demonstration it shows first 18 and then we go from 0 to 99
and then we wait 2 seconds when it reaches 99 this is 100 milliseconds between and when
it goes down I put 50 millisecond so it goes very quick and then two seconds stops and it goes back
to this number at the moment I’ve activated the decimal point this decimal point if I this was
zero in the code at the moment at the moment I’ve activated the decimal point if I change this back
to one and upload the code you will see that it will not show the two what the decimal point
repeat
thank you for watching this was how to use two digit seven segment display with Arduino with
easy code if you have comment or question please leave a comment below the video in this
in the comments section I try to answer and reply please make sure to subscribe
by clicking at the subscribe button in here thank you thank you for watching if you learned
something and found this useful please thumb up as this will help my video in the search algorithm
of YouTube if you have comment or question please post it at the comment section below
I try to answer and reply and don't forget subscribe so you get updates on my upcoming videos