arduino 74hc595 library
So what does IC does is that it it is able to shift multiple outputs so by using three pins on the Arduino we’re able to control eight LEDs and to just give you an idea of what this IC can. Do. You have a small scrolling example for the eight LEDs on my breadboard, for this particular tutorial you’re going to need an IC, so a shift register the one that I’m using I’m going to link for to the datasheet down below you can buy it almost anywhere. Sparkfun amazon, ebay, digi key now you’re going to need some jumper wires. As you can see, I have a lot of them on my breadboard you’re, going to need some current limiting resistors, which we’ve discussed in a previous video going to need a bunch of LEDs, and these are just very basic abilities and you’re going to need a breadboard. As well as your Arduino without any further delay, let’s take a look at datasheet for Ric, alright, so here’s the data sheet for our 74 hc5 95 shift register and, as you can see, we can find a bunch of valuable information I’m going to post this link Down in the video, if you want to get a more detailed view, you get all the pin outs you get the layout for our device, which pin goes where but, more importantly, we get a description for every pin. So, as you can see, we have. These are q1 q2 through q7.
Those are the pins that we’re going to use to light up two LEDs. Actually, it starts with Q 0, which is on the other side of the IC versus all the other ones, but we got these. These function. Descriptions within this table which are going to allow us to basically configure the device as we want, and you will see later on how we’re going to program this based on these. But in a nutshell, what you want to do is look at these different functions and the side of what you want to do, or what what you need the device to do so in this case, we would like to shift a value. So in this case, they’re setting on input of high into the shift register and as you can see it says, contents of all shift register stages are shifted throughout, which means that basically you’re cascading each element into the next one and shifting a new one into the Shift register also, the very important function is, as you can see, contents of shift registers are transferred to the storage register and parallel output stages. What that means is you have shifted in your values at this stage, but you need to out actually instruct the device to output what you want. So basically, the final result to light up the LEDs and the way this table works. As you can see, they have a description of what’s going on so here it’s. If you go from low to high voltage on your sh c, P pen and you’re going to keep these as they describe you’re going to execute this function, and in this case, if you go from low to high on the sdcp pen, you’re going to execute this Instruction, so this is obviously very important, it’s going to play an important role and the programming for this device.
Lastly, what else do we want to see umm? Also from this diagram, we cannotice that the enable pen is basically just allowing us to either display the basically have an output or not have an output. Also, the mr, the master reset pin has to be has to be constantly high for us not to reset the values completely. So those two pins could just be a a set value in our case, and we don’t need to worry about them so and on essentially we’re going to be using three Arduino pins to control eight outputs or eight LEDs in this case, all right. So let’s start writing the software all right, so let’s start defining our three pins. The first one is going to be the GS bin, vs, pin let’s, set it up on pin 8 of the Arduino and SD CP, and once again, all these pins are defined in the in the datasheet. So if you want to reference anything back and see what they do for yourself feel free, we are going to declare our setup, so this is, as usual, you always have to do this for the Arduino pin mode. All of these pins are going to be outputs. Obviously, I’ll put this TCP HTTP we’re, going to declare a function so right, reg function, we’re also going to set up a registers array of eight since we’re, going to have eight pins. What else so let’s declare our function right, reg, okay, so in this function, what we’re going to start with is: did it digital right, this hcp and too low? What this does is we’re going to start basically initializing all of our registers, one by one so we’re, going to set the spin to low we’re going to declare a four function in which we’re going to declare.
I is equals to 7, so we’re going to insert register. I mean register values in a reverse order to zero. So in this for loop we’re going in this for loop we’re going to shift in the value that we have stored in the registers array, one by one. So, in order to do that, we will start by by a digital right of the sdcp and lo we’re, going to write the value of the register, so in this case, digital right, the s10 and here we’re going to pull the value of the register. So right registers I and then the drill right, stcp and hi. So, as you can see, we’re creating the soil low to high transition here, so sdcp goes low and stcp goes high, and this is this is what I mentioned in the datasheet that we’re trying to get the transition to call that basically function of the IC and We’Re going to close the function with a sh, CP n hi, so once again anything in between these two, you get the transition of the SHC peepin from low to high. So this is going to basically save our values and output them onto the register. So, as always void, loop get open close, and in our case I mean I created a a very simple double for loop, which will cascade the LEDs, so let’s just do that into a equals zero I smaller than nine PI, plus plus within the for loop.
What I’m doing particularly, is declaring registers hi one by one, so it just there’s AI is equal to hi, followed by a delay. Follow registers. Sorry right right, so our function, which is going to write the set registers and another for loop, which is going to be int, I equals 8. So obviously you want to reverse the LEDs so to make that like wave pattern I bigger than 0, I plus plus then close just close up close the for loop, ok and here it’s, going to be basically the opposite, so registers I low delay 100 and right. The register see if we get any errors. Digitalwrite rates go okay, so that works, let’s upload it to the Arduino and we’re going to take a look at what we’ve got all right. So I just wanted to take a look at the circuit that I’ve built and sort of explain what’s actually going on. So, as you can see on the right, we have the the IC and we have the connections that are made to the Arduino. So obviously your VCC or ground, you have to connect them so ground VCC. The master reset, as I explained earlier, has to be pulled high in order for us not to basically clear the register. The register so that’s just permanently pulled up. Dependents grounded. Is here it’s the enable and if you look in the datasheet it’s, an inverted pin so that’s why it’s grounded it’s instead of pulled up but in reality it’s actually being pulled up inside the shift register, all the other, the other eight q, q0 2 Q.
7. Pins are connected to an LED through a current limiting resistor and I’ve explained the cauda calculated these values before. So, if you want reference those tutorials, the pins, 8 9 10 are our well Arduino. Pins. 8. 9. 10 are connected to SH, CPS t CP and the des pins so we’re inputting the register value through the d s pen and we’re toggling these inputs in order to perform certain functions described in the upper in the datasheet for this device. So let’s take a look at the actual circuit and how it performs alright. So, as you can see the breadboard circuit, we have all our. This is q0 let’s go into the first LED, and this is q1 through Q 7, which goes to beach, LED they’re, all plugged in with the series resistor and all of them are grounded. Just like I explained it in the schematic. We got power and ground going to the Arduino board, so the white wire here it’s the ground, the red is the power and we have three control wires, going back to the Arduino pins, eight, nine and ten and, as you can see, we are shifting through our Leds and they’re, going up one by one then going down just like we were all in the software, so feel free to modify the software showcase. What you’ve got, let me know if you have any questions, make sure to comment subscribe. That would be very helpful and let me know what you what else you would like me to make in the following tutorials.
Thank you guys very much. Hopefully you enjoyed this third tutorial.
arduino 74hc595 library Video
arduino 74hc595 library news
Posted on Tuesday May 07, 2019Lots Of Blinky! ESP32 Drives 20000 WS2812 LEDs Hackaday … Continue Reading »
Posted on Thursday June 14, 2018General Purpose I/O: How To Get More Hackaday … Continue Reading »
Posted on Saturday January 12, 2019Addressable 7-Segment Displays May Make Multiplexing A Thing Of The Past Hackaday … Continue Reading »
arduino 74hc595 library Social
🔬 Now that you’ve gotten your feet wet, dive into the kit and enjoy all nine experiments. Order yours today: http://bit.ly/2MnQ7fr
Originally posted 2016-03-11 22:18:31.