Welcome to Robojax. My name is Ahmad Shamshiri and I am presenting this tutorial from Canada.
Hi, Welcome to Robojax. In this video
I am going to introduce this
LM1637 Seven segment display
so this is a device you can use either
with Arduino so it can show
as counter or display let's say a number like this
or may be you just want to display
a counter something like to to count up to 500
and start over again.
So it can be used in many ways and applications.
it is very easy to use.
Let me explain how it works
It has 4 pins.
VCC, Ground (GND)
So these two pins
The last one is GND and this VCC
and then we Data input (DIO) and Clock (CLK)
in our case I'am just connecting it to Arduino here
to 5 V as you can see
to 5V and to Ground. this red and black.
so VCC (5V) is connected here
and then ground (GND)
and then the Data pin
the data pin (DIO) will be connected to
Pin 3
and the clock (CLK) will be
connected to pin 2 of Arduino
so my code will be displayed now
To get the code,
The link for this page is provided in the description of this video and
Go to this address once you click on that link
it is a Gethub page
TM1637 just click on this
"Clone or Download" and download it
Once you download it, click and save
then got to the folder you download it
I am using Chrome and going to "show folder"
This is the downloaded file here.
one way would be to just Right-click
Select 7-zip. 7-Zip can be downloaded form 7zip.org for free.
and click "Extract Here".
Once you do that
You will have this folder.
TM1637 master
so this is the folder with all
examples and codes
Go back, you copy this folder by Right-clicking
and copy it and then
Go to your Arduino folder
In my case I have not installed Arduino ICDE
I have just download and run it. it is called Portable.
So go to the "libraries" folder
so this is the Arduino that I run
go to (double click) on Library and somewhere in the blank spot right-clock
and select Paste. and then the folder for driver will be here.
that part it done. Now just open your Arduino IDE (arduino program)
and open it
the got File->
Examples ->
and scroll down
until you see
TM1637 Master and TM1637 Test
so this is the file you will open and
work with
let me explain some
portion of the code,
because there are so many things and we don't need to know it
to make it work for us because this
the only important pin is the CLK pin defined pin 2
unless you use Arduino for other
purpose , I suggest keep it as 2
and the DATA pin DIO
make it as pin 3. So that is it.
Rest of this code is example of different features of this library
so let me
run the code and we will see it
I am just uploading the code
this is the old code that was running. So just wait for it.
The code have been uploaded.
The first thing it does, it prints all segments and all digits like that.
so it sends all the data
after that it prints thses
random values
here it starts from 1 to 7
and then all multiple of 7
with some values that you see here. this is the one
after that it goes from 0 to 3
and displays
4 smaller numbers
so these are the values.
and then you will see all those numbers.
then it sets all digits to zero.
including the colon :
then here is 153
and then 22 that you see on screen. zero
and all those numbers and
now it tests setting the brightness
you see
after that
it goes to ON, OFF
this code is for ON, OFF
so ON and OFF
and then it prints "dOnE"
you will see the text here.
so "dOnE"
once it id one. while(1) it
means infinite delay so it stays here forever
until you unplug the power of Arduino or press the "reset" switch.
until you unplug this it stays there
with the word "dOnE" on screen
So, because it does so many other things
for many options, I will just go and explain
the simplest way that
I've tried.
You see the master file that we downloaded is required here in the code.
so you have to have this one , otherwise you will get error
The instruction that I give you to put the file in that folder
will include this and that issue will be resolved.
so you don't worry.
so pin 2 is clock, pin 3 is data
accordingly set it because here
the data and clock
for those pin values
clock is connected to pin 2 and DIO is connected to pin 3
this 2000 millisecond is the delay between some actions that we use
here . I will explain it
this defining
the display object
but don't worry about it.
don't touch this as well.
we don't touch these
and here
k is from
main original code.
First we are setting the brightness of the display at maximum
so every time the loop() runs it will be at maximum.
because we set the display brightness from this value, this 0xF means
maximum
so it can be 0x1, 0x2, ....0x9, 0xA, 0xB, 0xC, 0xD, oxE and 0xF (hexadecimal values)
so that will be the maximum
and then we set the display
Now let me explain how it works:
so this is setting the brightness. So you leave that
for the maximum brightness
to clear the screen from values, use
these are the values for each digit
first digit, 2nd and 3rd digit and 4th digit
0x means HEX value
and 0 means actual value. s
so we are setting zero for all digits to become blank. Then we use setSegment
we are settit with this data[] comes from here
don't worry about it.
these two lines make the screen clear or blank. As simple as that.
otherwise the previous value will stay on the screen
this showNumberDec
refers to decimal number
so this is the actual
human readable value (23)
let's say if you want to display 23,
put fales here
and then
this fales it remove zero before the value
to show zero on the left side
to display it and then
we have 2, 2 means this number we want to display has 2 digits
so it is number of digits in your value
if you have more digits like 124 , then make this 3
and this 2 means start from the,
position from left, so zero, one, two , three
so this
so if we say 0, it will print 23 starting from here
2 and 3
so let me show you
so you see 23 starts from here.
and after that
and I will make the screen clear (blank)
the job of this line is to blank it. Let me comment this out and then show
you so you see that the 23 stays there
and then 153 will be printed on top of it.
so now, look
23 and then 153. Because 2 is there
you see 153
so you have to clear this screen if you
you are printing something else.
if I set this to 3 however
make sure to understand it
zero, 1, 2, 3
so this is the 4th digit
so 23 starts, 2 here and then 3
so the 3 is out of the screen
so make sure you understand that. this one
it should be set accordingly.
if it was 1 digit, it would work.
so you see the value is out
and for 153, because it is 3 digit, we put 3 here
and it says start from 1
if we put 0, it will start from here
if this parameter is set to zero, this 153 will start from here
let me show you how make a coutner
I wrote a code here
simple it just writes
from zero to
500
I am clearing the screen first.
so this is a loop
set i from zero
and i smaller than 500
then whatever is i, "i" becomes 0, 1, 2, 3... up to 500
so it prints that 153 and it
goes to 500
when it reaches to 500, the loop
goes back and writes 23
when this loop finishes
it goes back here and
and starts again. Setting the maximum brightness and then
setting the data for the blank
so you can have 4 gitis which can go to 9999
so you can use this in distance measurement (the link to my videos are below this video)
some kind of counter
equipment on door, number of
movement of stuff
or with the gesture sensor
or if you work a little hard, you can make a clock using this
so I might make a video on clock
and post the video
but for now
all this code and examples will be posted on
and you get them by clicking on the link in the description below this video
or you can go directly to www.robojax.com/learn/arduino
Thank you for watching. Please thumb up 👍 the video as this will help my video.
Also please subscribe to get updates of my upcoming videso.
Typed by Ahmad Shamshiri on Mar 10, 2020.
I spent my time to help you learn. The least you can do for me is not to skip the ads when displayed and watch them