Using Shift Registers to Get UNLIMITED GPIOs for our project !!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
a couple of years back I made a video about increasing number of inputs offered node MC board using a multiplexer demultiplexer module and that works really fine and one thing was clear with me after that video which is multiple inputs with the Lesser number of gpio pins I'll definitely use that module but will it worked for providing multiple outputs as well what do you think well do click the pause button and comment below will it work for multiple outputs or not done with that well let's do a little bit of research so couple of days back our favorite content created Electro noobs uploaded a video using that same module and covered all the things about it and he even tried to get multiple outputs using that module and he succeeded as well research complaint right well if you look at it carefully then he is controlling One LED at a time but will it work for controlling all the LEDs simultaneously well let's just test it out so here I have uploaded a sample sketch to Glow all the LEDs connected to the mux dmux module but as you can see the LEDs are flickering so you've got the point using this module will be able to control only one pin at a time and if you want to control all the pin we won't be able to do that simultaneously it will have a kind of a delay in between so we'll be observing the flickering effect will be observing this really triggering effect and all kind of stuff so now here comes the topic of our video which is to control multiple pins simultaneously using lesser number of GPI pins and our Target of this video is to control eight relays or 8 LEDs simultaneously using just three gpio pins so yes that's the topic of our video and after watching this big intro if you seem to be interested in this kind of topics and contents well consider subscribing Channel because I come up with these kind of you know content in the field of electronics iot and automation on this channel every week that being said let's start with controlling multiple outputs using lesser number of gpio pins IR it will be really very useful let's get started before starting the video let me tell you one really interesting and useful feature of our sponsor LTM which is a PCB designer based software company and that feature is called as design review using LTM you can add any member to your project and after that they can highlight any fault in the schematic or can report availability of components in the inventory on the PCB to your designers so that they can visualize this components and can work upon it to provide a smooth flow of PCB production even if they both are in any corner of the world so that's the design review feature and even you can try out this and many other features of LTM for free by just clicking on the link manager in the description as you'll be getting an access to free trial version using that link now let's start with our video so for achieving that goal we'll be using a serial in parallel out shift register now here two question arises first is what are shift resistors and second what is serial in and parallel out well let me tell you so shift registers are basically the combination of digital circuit in which output of one flip flop is connected to the input of other flip flop now if you don't know what flip flops actually is then flip flop can be considered as a digital memory which can store only one bit either 0 or 1 and as multiple flip flops are connected together we can shift the output of one flip flop to other flip flop and hence the circuit is called as shift register so generally there are four kinds of shift registers which are serial in serial out in which the input is given serially and we are also getting the output serially second is serial in parallel out in which we'll be taking the input serially while we'll be getting the output parallelly and similarly we have parallel in serial out and parallel in parallel out so we can choose any of those shift registers based upon our requirements and applications so now coming back to our agenda which was to increase number of outputs with lesser number of GPI panes and to achieve this goal we'll be using a serial in parallel out shift resistor now let's have a detailed look about how this shift register will work how many inputs we need to connect how many outputs we'll be getting and everything about it so here I'm using this 74595 shift register IC and we'll be using it with our esp32 board and some LEDs as an output indicator and we'll be connecting them according to this connection diagram so that was all about the hardware part now let's see how to program it to actually use the shift register okay so here is the basic code to use this shift register using any of the microcontrollers so the three major pins of the shift register are data pin latch pin and clock pin now data pin is pretty simple as we are using this serial in parallel out shift register then we only one single input pin and that is nothing but the data pin so from a data pane using data pin we'll be sending our data serially now the data bin is connected to the digital Bin 14 offer esp32 Board second is the latch pin and the clock pin both the pins are actually the clock pins but have the different different purposes this particular clock pin is the clock of this shift resistor based one way the data will be shifted from one flip flop to another flip flop while this clock or we can say latch pin is responsible for locking the data into that particular flip flow or latching the data to a particular flip flop okay now when we go through this code the purpose of both clock pen and latch pin will be cleared to you okay after that we have declared all the pins as outward because all bin will be working as as an output only now here inside the void Loop we are running a for Loop starting from I is equal to 0 to I is equal to 255 basically it's the binary counter kind of project that we are making here now here inside the follow first of all we are you know uh making the latch pin to go at the low state or digital zero after that we are using a shift out function and after that we are again putting that latch pin to high state so basically we are you know making a digital uh clock you can say so what happens is whenever the latch pane goes from low to high whatever the state uh of that particular flip flop is it will be locked or it will be latched okay so that that state will be a fixed State you can see okay so now the state will only change when again that latch pin goes from zero to one okay so it is changing at the rising edge of the latch pin okay so that's the purpose of the latch pin or you can say latch clock now let's just see the purpose of the C shift registered clock or the clock pin so here it is use used inside the function called as shift out so what we are doing is we are first of all lowering down the latch pin and then we are serially sending the data to the data pin which is the serial uh input of the shift register based upon the clock that is the clock for shift register and how we are sending is we are sending with uh the format which is MSB force that is most significant bit as the first bit and what we are sending is we are sending the data as I which is nothing but a counter starting from 0 to 255 okay so this data is sent serially to data pin and after that we are you know making that last pin high so it's a rising Edge so the data will be locked okay and we are repeating this step at a delay of 50 seconds oh sorry 15 milliseconds so this is a kind of a binary counter and after that what we are doing is we are first of all turning off all the LEDs and after the delay of one second we are turning on all the LEDs okay so that's a simple project that we have made and if you look at this carefully we are you know doing the latch low and high whenever we are sending the data okay again low and high and in between we are sending the data so this is kind of a basic structure or basic code using which you can use the shift register for you know driving multiple outputs using just three uh digital pins you can see great now I'll select the right board and com board which is already selected and straight away hit the upload button okay as you can see the code is successfully uploaded and I will click on the reset button to start it all over again and as you can see first of all it is started the binary counter with all the eight LEDs and as soon as it completes the counting up to 255 it should blink with all the LEDs let's just wait for that particular thing okay so it blinked for uh once a second of delay and yeah we are able to control all the LEDs simultaneously using just three digital pins of our esp32 board and we can do it with any of the microcontroller board isn't this amazing and now in your case if you want to control more than eight appliances but still you have only left with three GPI of pins well you can still go with the shift registers in the Cascade mode yes you can attach one shift register with another and create a series of shift register and control all those uh appliances or LEDs or pins using just three gpio pins of your microcontroller let me show you how to Cascade two shift resistor to control 16 LEDs with just three GPI pins so for that you need to connect two shift registers and LEDs and microcontroller according to this connection diagram and after that in the code there is no much change there is only slight changes compared to the previous one which is uh first of all this shift out function is able to handle only one byte of data that means only eight bit it can handle okay but uh as we are using two shift register each has one byte of data like eight LEDs on it so we require two bytes in total okay so what we can do is we can shift the uh you know two bytes into high byte and low byte and we can use the shift out function for two times so this function will be responsible for the high uh higher byte you can say and this function will be responsible for the data in the lower button we can control uh like up to 16 appliances using this code other than that the rest of the code is exactly the same so first of all we are turning on all the 16 LEDs then we are turning off all the 16 LEDs and after that we are running a for loop with the delay lesser than before which is five millisecond and it is like working in a binary counter manner okay so I already uploaded the code onto this esp32 board and if I turn on my smartphones camera to let you know how this works then here's the working of that project let me just press the reset button so first all the LEDs are on all LEDs are off and now as you can see it started the binary counter but now with the help of two bytes or you can say 16 LEDs as we have connected two shift registers uh in series with each other okay so yeah but still we are able to control all the 16 LEDs by just using three GPI pins of esp32 board and you can increase it according to your demand your choice your application your requirement just connect one shift register with another of course the code will become a little bit complex But ultimately you are saving a lot of gbr pins in your project okay so yeah that was all about using shift register to extend the gpio pins to control the output all output simultaneously unlike that Max DMX IC that we have seen at the beginning of the video so yeah that was all about using shift register to get multiple output pins by just utilizing three GPI pins of our microcontroller and as I said this can be used with any of the microcontroller that you have I have used esp32 but you can use ESP right266 Arduino and wait esp8266 that esp26601 has in total 4 gpio pin so we can use esp826601 generic module for making a decent level automation project like controlling up to four or five AC appliances also controlling speed of one AC fan by just using esp01 how's this project is it interesting well do let me know down in the comments of the video and if you all find it interesting well I definitely try to make the smallest home automation project using the Chota Wala esp8266 board and shift register and pandemic appliances I'll do that everything do let me know your suggestion down in the comments of the video and yeah do click the like button if you really find this video interesting and got to learn something new from it and yeah that being said I am is ending this video here and now just wait for me actually then explore learn share with me techie SMS
Info
Channel: techiesms
Views: 81,629
Rating: undefined out of 5
Keywords: techiesms, electronics, electronics projects, Shift register, 74HC595, 74595 shift register, 74595 with esp32, Esp32 shift register, Cascading shift register, shift register counter, shift register esp32, 74595 arduino code
Id: TAGbS6k2z-Q
Channel Id: undefined
Length: 12min 40sec (760 seconds)
Published: Sat Oct 01 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.