This is the seven segment display and beside it you can see the pin out of seven segment display. So there are two type of seven segment: one is common anode and one is common cathode. So if i say seven segment, it means uh. There are seven leds, so you can see a is the first led, a b c d, e, f g, so there are seven led all are actually compact together and uh. Two pins are common three and eight. So there are two type, as i said, common anode and comet cathode in common anode. This eight and third pin will be positive and other spin will be negative in order to grow these led to other pin. You have to give negative voltage if it is common. Anode, but if it is common cathode, then third and eighth pin, which is common, pin, will be negative wrist. All of the pins will be positive, positive means. If you give positive voltage to rest of the pins, then only the led will be turned on. So lets start the session so im going to do this interfacing with register level coding, because if you do interfacing with uh with arduino function, then the program will be very lengthy. You have to define you have to declare each pin and for each pin you will be writing three output. Four output: two output, like that you will be doing, but here in this program we are going to use port d, which has eight pins starting from zero to pin number seven.

So we will connect this seven segment on port d and we will do register level coding and for this we need a array, so we will use array also. So here you can see d0 to d7, so these are eight pins. We are going to use in our program for interfacing this seven segment module. So here you can see if lets say i have to print zero. If i have to display zero from seven segment, then a b c d, e, f g, so a to f, should be on g, should be off. Even h is basically d d p. This is dot so, as we will not use, so h will be always zero, so for display zero. Only g should be high. This uh sorry g should be low. Rest of the pin should be high because i am going to use common cathode now lets. Take this so, as i said, ads at should be low and 0 should be low and app should be high, e should be high, d should be high c, should be high b should be high and a should be high. So this is the hexadecimal coding, so we have to what is the value of this? What will be the value of this? The value of this will be f, so this will be f and what is the value of 0. 0. 1. 1. 0. 0. 1. 1. Will be 3 so for display 0, we have to write for 0.

We have to write 0x. 3F. 0 x means hexadecimal value 0x 3f, this value so for 0 to 9. We have to write each value so that we can make a counter which start from 0 to 9. So for 1. What will the value for 1 so for display 1, only b and c should be turned on this to all of the pin should be turned off so lets do this, as i said, b and c should be turned on test. All of the pins should be turned off so b and c will be on this. All of the pin will be off. So what will be the value? The value will be 0 x, 0x06 isnt it. It will be 0x06 because here you can see, all four bits will be 0 and 0. 0. 0. 1. 1. 0 is 6, so 0 x, 0 6. So we will just make a list of all of the things. Then we will put this value in array for 2, a b g e d and c a b g e d right yeah. This should be high, so lets take these things here, yeah now its okay now lets erase this part yeah. So for 2. What things will be high for 2? A should be high b, should be high, g should be high, e should be high, and d should be high c is will be, zero, f will be zero and h will be always zero.

So what is the value? Four bit and this four bit so these uh from d0 to d3 is called lsb. Lower significant bit from d4 to d7 is called most significant bit lsb and msb. So 1. 0. 1. 1. It is the value for 1, 0, 1 1. It will be b and what is the value of our 1 0 1. It is 5, so 0 x, 5 b, 0 x, 5 b. This is the value 0x5b. So first lets write these three and lets see it is displaying 0 1 2 or not so lets open. This tinkercad tinkercad is open. Lets take arduino already know i have taken lets make the connection first, seven segment lets pick from here. So if you write seven segment, you can easily find that yes, so lets pick this one and you can see this is common cathode. You can select here common cathode because we are going to use common cathode only lets make the connection quickly. This is required. So i will connect a register to this link and then i will just do ground a first. A should be connected on, pin number zero b should be on. Pin number one c should be on, pin number three two sorry, then d should be three e e. Will be e will be here, e should be on, pin number four f should be on, pin number five g should be on, pin number six as we dont need to do connection.

We can do if you want, otherwise you can leave. Also, all connections are done. Lets write the code, so we have calculated the three value only so first, let me delete all these things. We are going to do register level. Coding first lets create array, integer led uh. I have only taken three value, so lets write three zero one: two, it will start from array will always start from zero. So what was the? What is the value of zero zero x? Three f, then, what is the value of others? Lets see 0x06 and 0x5b. 0X5B only we have written these value void setup. First, we will check these things is working or not. Then we will try it for nine till nine also void setup theta here what we will do, ddrd equal to zero x ff. So i have defined port d as output, so if you dont know the register level coding, please watch my previous video. I will add my that link in description white loop thats it. It is very simple guys only. You need to write 5 line code for printing the value of these things. Now i will just do for integer. I will just create a variable integer. I then i less than equal to 2. I will start from zero. Then i plus plus, because i have taken only three value thats, why im running this loop three times and inside the for loop? I will just do port d equal equal to led i thats.

It lets put a delay also for one second, so that we can see delay. Spelling is wrong. Lets correct that delay, correct everything is done. You can see. It is very simple. Now lets see what is printing lets simulate. This is around integer led 2, 3 for in teaser 0. One two, oh lets, uh. We have to change three now its correct. Now you can see zero one, two zero one, two zero one, two right, because we have put it r till three: three value we have given thats, why it is displaying three so lets say we have to increase lets say we have to now display three. So what will be the value so same thing? What you can do just let me raise these things for three, which pin should be high for display 3, a b g c d, only except e and f every pin should be high, so accept ef. So let me do ef 0 and rest. All of the fin, even h, will be always zero. As i told rest, all of the pin will be high right. So what is the value of this hexadecimal value? F? What will be the value of this? This will be 4, so for 3, 0 x, 4, f, 0, x, 4, f, thats. How you can do for 4 also for 4. What will be the value for 4? The value will be for four f g b c should be high, so f g b and c should be high rest.

All of the pin should be low. H should be low. Now. What is the value? 4 4 bit? This is what 6 again. This is also six, so zero x, six six zero x sixes. Now i i think guys you got an idea how to do this thing, so you can add. On till nine i will just show till 4 hope you got the idea. So lets put the value for 3 and 4 0 x, 4, f and 0 x. Double six, so lets come to the code. So two more thing: we have added 0x 4. What is the value for 3, 0 x, 4, f, 0, x, 4. F then, 0 x, double 6 0x doubles correct, yeah. So now we have to change these things because we have added five element now so five and we are going to run these things starting from zero one, two, three four and then everything is correct. Lets simulate now one two, three four zero one, two, three four! So as you can see guys, this is very simple, but if you use the arduino function, the program will be very lengthy. It will be 20 line of code and using register level coding. You can minimize the code. Even the execution of the program will be very fast if you use register level coding. So i hope you like this video. So if you like, please hit the like button and subscribe my channel.

https://www.youtube.com/watch?v=bq4yHoBZup0