HI! Welcome to an Arduino tutorial from Robojax my name is Ahmad Shamshiri
in this video I’m going to introduce a four-digit 7 segment display based on
ht16k33 based on this chip that can do everything that you expect from it using only four wires
which uses I square c communication you can easily display integer if you want preceding zeros
or if you want to display a negative integer or display float display float with multiple digits
float with negative blank or use it as a clock as you can see with a counter and negative
or positive or display hexadecimal values increase or decrease the brightness
or use it as a UV meter or level of sound or something that you want to display
or decrease or stereo in both direction
or even use it as a raw display that you can turn on any element
in any way you want you can use multiple of these display with Arduino
you can get the code for this by clicking at the link below the video in the description which
will take you to robojax.com/learn/arduino let's get started with this and this is the
display when you purchase it they will ship it like that there is a protective sheet on it
so you have to remove it
I have only four wires here this is not soldered once it arrives you have to solder it this is a
main chip the chip is ht16k33 for Arduino there are so many options to display but
this display was the best one that I finally found where we can display floating point where
we can display an integer we can use it as a clock we can even use it with a negative value
so this is the best ever you can get because it can use this ice cream communication only four
wires and it can be used for everything that you need the brightness can be set
I will create a lot of videos to this to use this with temperature sensor voltmeter potentiometer
with anything that I have with it needs four digit I’m using it and also I’m going to demonstrate it
with using a clock because it has column and it can easily be used for many other purposes the
products have been introduced by adafruit and they're selling it I will provide you the link
that you can get it from amazon or from AliExpress I bought it from this store from AliExpress for
to the 30 cents Canadian it's around two dollars u.s with some shipping that you can wait and also
and if we search AliExpress there are different variation of this available
but this display is available widely this can be viewed from further distances because of the
brightness of the screen and the size and from the code you can set the brightness at any level
between 0 to 15 I believe 15 levels of brightness you can set it because this uses I2C communication
so these two pens can be shared on the same bus and each will have different address which you
could you can set on the code which I’m going to show you for two of this and you can apply
the same method for multiple of these the chip is made by HOLTEK you can get more information
from this website I will provide you the data sheet the chip is offered in 20 pin package
24 pin and 28 pin and on this module we have this 28 pin package 28 sopa operating voltage is 4.5 to
5.5 that's why we are using it with 5 volts I2C bus interface this is the model of the display
but we should not be worried about it because library is taking care of everything this is 0.56
inch in terms of length of the digits and as you can see we have column and we have decimal points
from the librarian from the code you can turn the column on and make this a clock so
we will send hour and minute and if you want to display decimal point some voltage with floating
number these decimal points any of these can be turned on and off at any moment that you want
let me explain now the wiring we have from five volts ground a4 a5 as you can see that's this five
volts is green, green is connected on the left pen ground is blue connected to the second one
and then a4 this purple is connected to the third one and the last one is connected in here
so they have been connected accordingly and you will not make mistake
now let me explain the code I’ve downloaded the library from this URL
author is Rob Tillaart and this is the link when we visit it we can download the library
and get it and if you click on tools manage libraries
wait for this to complete
and hair type HT16K33
you will see all this library the first one is Rob Tillaart I’ve installed it you just this
is installed for you it will be just install click and install it and that the installation
is complete once you install the library you can access the example by clicking at file
examples scroll down until you will see somewhere on the left
ht16k33 and these are all the examples that are available if I click on GitHub
these are the examples that is available in your Arduino uno menu demo 1 vu cache
display integer display raw display time dual display and test print float and here
you can set display on or display off to turn it on and off you can set the brightness between 0 to
15 so 0 is dim 15 is you just put the number here and if you want to blank the number of blanks so
0 to 3 how fast it blanks and here's some data types you can display integer you can display
hexadecimal and when you display dates you send two portion for example the month and the day you
just put comma and like that month day or day or hour as a separator and also if you want to
display time you have to send minute an hour and then for column we have to turn it off separately
for float you just put from minus 999 because it's four digits
up to 9999 and there is no overflow indication I want to use it a level meter for something
you can send you can display vu left or view right and now let me explain the code that
I’m demonstrating because there are multiple examples I put them all together for the main
features that we want first this line includes a library which I’ve just explained to you
from this library class we create this object called segment and we pass the I square c address
and these are the values that is used inside the code
inside the setup initialize the serial monitor with 115 200. if you go and click on tools serial
monitor you will see the serial monitor or press shift ctrl shift m or press this and then here on
the right side you will see this number must match otherwise you will not be able to see this text
this line initializes with seg dot begin this line initializes the seven segment display this line
initializes the I square c communication using the wire class
and this turns on the display segment dot display on and then we said number of digits that you
want this is just displaying a text on the serial monitor and then we this display test is testing
all the digits on this when I turn it on let's see I’m restarting it that test is this line
and then we turn off the display after that keep it for one second off you see after this it goes
off and then on so this line is taking care of that and then it turns the colon false after that
we see one digit and display 64 for five seconds and this this line displays with four digit that's
64. this line displays 74 with negative as you can see this line displays 33 now point
five with one decimal place and next it will be displayed with three decimal places
after that we have one decimal place and then one decimal place with this turn it off turn
it on we set the the display with two digit and this line is displaying clock 18 and 25
after that this is just a counter that adds the number from minus 300 to 300 and then after that
we have this value of hex and then this loop is continuously printing the hex value with
just added value and also increase and decrease the
brightness and here's the code how to read the potentiometer
so we define this object as I mentioned before we read the analog zero pen
the value is stored here in a sensor value and then we get the same sensor value multiplied by
5 volts divided by 1023 and the calculation of this is a voltage and here we say print voltage
using display float with one decimal place if you want two or three decimal place just change that
and this 500 millisecond is the delay if you want to display it
faster with faster refresh rate reduce this number for example make it 50 or less or more
and here is a demonstration of reading potentiometer 5 volts and rotating it
the voltage is reduced and red very nicely
this is now with three decimal places and here I changed it to one decimal place
just adjusting it
and here's the demonstration of using two displays simultaneously
and here's the code for it first we define the display on the left side with the I square c
address of 71 and the next one we call it right and 0x70 that's the hex value of 70.
so we define the address we get the class and we define the display on the left side
which is this one and we define the display on the right side and for each we pass I square c
address and they must be different and after that we just use left and right to refer and set them
thank you for watching this was how to use this ht16k33 four-digit 7 segment display
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
Related Videos
this is based on sun 74 hd 595 chef register and two digits have been arranged and the module
something like this when you buy it there will be no pens 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 label here and as you can see you can cascade it also if you have other
digits attached to this but for now these two will be enough because we have four digits and