Post Top Ad

Sunday, June 9, 2024

The 74HC595 SERIAL circuit that shifts and stores Bits


 The 74HC595 SERIAL circuit that shifts and stores Bits

This is my first instructable, hope you will like it. I have been playing around with LEDs for a while and I realized that I am pretty much limited with Arduino pins and can not make huge projects which requires a lot of pins. This is small project with main focus to drive LEDs by using Arduino pins as less as possible and it demonstrates how to add infinite number of pins. In this particular project the 16 LEDs are driven with just only 3 Arduino pins. The key element is shift register. Each 74HC595 shift register can drive up to 8 LEDs and by daisy chaining registers it is possible to extend Arduino 3 pins to infinite number (for large number of registers, there could be problem with clock which is required for shift registers).


- Arduino UNO (x1)


- 74HC595 shift register (x2)


- LEDs (x16)


- 220omh resistors (x16)


- A lot of wires


- Two breadboards (one with 400 pins and another with 830)


- Potentiometer, to control the brightness (optional)

Make the circuit (see above) and connect the first shift register as follows:


- GND (pin 8) to ground


- Vcc (pin 16) to 5V


- OE (pin 13) to ground


- MR (pin 10) to 5V


- DS (pin 14) to Arduino pin 11


- SH_CP (pin 11) to Arduino pin 12


- ST_CP (pin 12) to Arduino pin 8

Connect the second shift register exactly the same, but connect the DS (pin 14) to first register pin 9. After that connect pins: 1, 2, 3, 4, 5, 6, 7 and15 from both registers to LEDs. This connection makes all the pins always active and addressable, however when the Arduino is powered up some of the LEDs may be turned on. Solution for this is to connect MR (pin 10) and OE (pin 13) to Arduino directly, but it this way you have to sacrifice 2 Aurduino pins.


To add more shift registers connect them like the second register. Always connect MR and OE pins directly to Arduino and DS pin to previous register.


If you want to regulate the brightness of LEDs then connect potentiometer as shown in picture above to control resistance for all LEDs. However it is optional and you can get along without it.

The existing codes are designed to limited number of shift registers and there is no universal function/method to do it. As a software developer it is unacceptable for me and I am used to make everything as dynamic as possible with no limitations. 

I redesigned the existing code samples to allow you to use unlimited number of shift registers. See code below:


In the final code I added several effects for those 16 LEDs. The effects are demonstrated in the video above. If you want to add more LEDs, connect more shit registers as described previously and change the value of numOfRegisters in the code (Also adjust logic for effects).


You can also use this code not for just LEDs only, if you simply want more pins for your Arduino use the regWrite(int pin, bool state) function to write state for any pin and there is no limit how much shift registers you are using , just change the value of numOfRegisters and everything else is automated.


 The 74HC595 SERIAL circuit that shifts and stores Bits

This is my first instructable, hope you will like it. I have been playing around with LEDs for a while and I realized that I am pretty much limited with Arduino pins and can not make huge projects which requires a lot of pins. This is small project with main focus to drive LEDs by using Arduino pins as less as possible and it demonstrates how to add infinite number of pins. In this particular project the 16 LEDs are driven with just only 3 Arduino pins. The key element is shift register. Each 74HC595 shift register can drive up to 8 LEDs and by daisy chaining registers it is possible to extend Arduino 3 pins to infinite number (for large number of registers, there could be problem with clock which is required for shift registers).


- Arduino UNO (x1)


- 74HC595 shift register (x2)


- LEDs (x16)


- 220omh resistors (x16)


- A lot of wires


- Two breadboards (one with 400 pins and another with 830)


- Potentiometer, to control the brightness (optional)

Make the circuit (see above) and connect the first shift register as follows:


- GND (pin 8) to ground


- Vcc (pin 16) to 5V


- OE (pin 13) to ground


- MR (pin 10) to 5V


- DS (pin 14) to Arduino pin 11


- SH_CP (pin 11) to Arduino pin 12


- ST_CP (pin 12) to Arduino pin 8

Connect the second shift register exactly the same, but connect the DS (pin 14) to first register pin 9. After that connect pins: 1, 2, 3, 4, 5, 6, 7 and15 from both registers to LEDs. This connection makes all the pins always active and addressable, however when the Arduino is powered up some of the LEDs may be turned on. Solution for this is to connect MR (pin 10) and OE (pin 13) to Arduino directly, but it this way you have to sacrifice 2 Aurduino pins.


To add more shift registers connect them like the second register. Always connect MR and OE pins directly to Arduino and DS pin to previous register.


If you want to regulate the brightness of LEDs then connect potentiometer as shown in picture above to control resistance for all LEDs. However it is optional and you can get along without it.

The existing codes are designed to limited number of shift registers and there is no universal function/method to do it. As a software developer it is unacceptable for me and I am used to make everything as dynamic as possible with no limitations. 

I redesigned the existing code samples to allow you to use unlimited number of shift registers. See code below:


In the final code I added several effects for those 16 LEDs. The effects are demonstrated in the video above. If you want to add more LEDs, connect more shit registers as described previously and change the value of numOfRegisters in the code (Also adjust logic for effects).


You can also use this code not for just LEDs only, if you simply want more pins for your Arduino use the regWrite(int pin, bool state) function to write state for any pin and there is no limit how much shift registers you are using , just change the value of numOfRegisters and everything else is automated.

No comments:

Post a Comment

Post Top Ad

Pages