hi welcome to an Arduino step-by-step course by Robojax
in this lecture we are going to see how we can use this four digit seven segment display
based on the tm1637 chip four digits when segment display which is very common module with Arduino
this module is offered in two different types smaller and larger this is offered at 0.36 inch
or at 0.56 inches and both of these are exactly the same in terms of functionality
the only difference is that this has decimal point which cannot be used at the moment but the rest
is exactly the same the size is larger and you will get it in red color or green color like this
and also there are a blue and white color of this is available the prices are almost
the same you can get them from eBay you have to download and install the library because
there are so many variation of libraries I’ll provide you the link from GitHub and also from
my website robojax.com that trusted version that works
the module has four pin and the other side that you see for pin is de pin ding on your application
we can solder the header this side or this side this usually shapes without the header is solder
so you have to solder it and in this one you have no option it will be only on one side
but in this one they offered in both sides and I soldered them on both sides and we have four pin s
clock clk dio data and out ground and five volts and this one it has been written like that
but if I put this here clock data in out and
ground and vcc have been swapped I don't know why they did this module is 65.7 millimeter
by 26.8 millimeter
by 12.3 millimeters the small one is 21.5 millimeter in terms of width
the length is 40.7 millimeter the depth is 10 millimeters
and this is the wiring diagram for this tm1637 four-digit display module I’ve drawn this circuit
using first thing and some editing in photoshop the from the bottom if you see this is connected
to the ground the second wire is the five volts I’ve been connected to five volts of Arduino
this is the data io in out this has been connected to pin 6 and this is a clock
this has been connected to pin 5. and this is the wiring diagram for the larger version
which has connected on both sides and it has some text and the decimal point looks below so this is
upright and the wiring is a little different and these ground and five volts have been swapped
from the bottom this goes to five volts the second one goes to the ground the third one this is data
and out have been connected to six as pin is a clock which has been connected to five this is the
wiring for the small version from the left side this pin have been connected to ground the second
pin is five volts have been connected with the red wire to five volts the third wire is the data and
out this is the orange have been connected to pin six and the yellow is the clock pin this has been
connected to pin five for this larger version the data pin the clock and that o pin is the same five
and six only the vcc and ground have been swapped from the left side red is connected to five volts
and the second pin is connected to the ground the data is the orange 2.6 and the clock is 2.5
let me explain the code the first line includes Arduino dot h that's a header file which is
included with Arduino ide you don't have to download or put anything in the library
but this tm163c7display.h a library that I will provide you the link you have to download it and
include it once you download in your computer it will be a zip file like previous videos
click on sketch include library add zip library and then point it to where you have
saved the file in this case I give you an example of a zip file just select the zip and click o pin
once you do that close this ide and reo pin it again and the library will be working with
examples and everything this line defines pin five for the clock we use cl k that's exactly
how it is printed on the module and then consects as data in out and this is a test delay time that
I will display all these information on the screen with this much delay this is just for test purpose
all digits this is because we have four digits and for each digit we need a value to
turn all the segments of this display so ff means and that's in terms of x that means all
the segments are on and this is when you test all the segments on you just send this to that
to this display and 0 0 0 means blank it will this is now 0 and this has some value
zero means blank so for the blanks we use another array
and here using the class we create an instance as an object we call it display and we pass
these two clock pin and data announcement this is as if I type here 5 and type 6 and pass it inside
the setup we set the brightness using display.set brightness and zero f is the maximum brightness of
this you can adjust it in case in some environment you need less brightness especially in darker area
every time you want to clear the screen from previous value we use display dot set segment
and then we pass this blank which we have defined above I just shown you
portion the three line is for to display this 125 this false means there is no zero if you want the
zero to appear we just type fall true this three means it has three digits the length and this one
means start with one that's zero that's one if you say two it will start from this point and now this
line prince384 with that true that's true means put a 0 in front of it that's why you see this
true but we don't worry about the number of digits and where it should start and the next example
22 with false two digit and we start zero one two from the second digit we started it and then this
zero means start from the third digit zero one two three from the three and the length is one
and this one is stored from the second and this starts from the one and this is starts from zero
and here this is the example that is included it does a lot of things which we don't have
time to explain you can look at this in order to understand it change and set this time let's
say for 20 seconds and every time this runs you will see and understand for example this is now
changing the brightness of the led and this is the portion of the code that we are in
and then it will print the word done in e and this is the last line that it runs
and after that we have it says while one this while one is used whenever you want
the loop to never end and stay here this is a very good trick to keep the loop stopped
and here is a simple counter if let's say you want to display the number from zero
up to two thousand and this is the loop the for loop that goes from zero to two thousand
and I changes from zero one two up to two thousand and we use display dot show number this and then
I that is decimal we are printing it on the screen so I zero one two three up to two thousand
after that here we wait three thousand millisecond three seconds and then this is the countdown
we start I by 1700 and then as long as it is bigger than zero this will continue and here
we are decrementing it here the I is being incremented and here I is being decremented
and it goes until it reaches zero and then stop seconds and continue with
the rest of the code that I’ve just shown you and here is the code that is running
it goes up to 2000 as you can see you don't have to define anything it automatically starts
from this side you don't need to mention the length you don't mean you need to mention the
position automatically it goes and now when it reaches 2 2000
we will go to the next loop which will start countdown from 1700
so it waits for five seconds three seconds here and then 1700 started and this is now count
um this was how to use the tm1637 this is very nice module yoau can do so much with this
and my application you can use it uh thanks for watching please make sure to subscribe
by clicking at the subscribe button in here thank you thank you for watching tutorial from Robojax
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 to get updates on my upcoming videos