This article is about how to expand easily and massively digital outputs by using 74HC595N shift register with Arduino Uno or Arduino Mega. Sometime in many electrical and embedded systems projects there is a need to connect and operate more sensors or other output devise into the arduino but there are no more output pins available in the Arduino board so to avoid this type of issue and extend the number of output ports with the help of shift register IC74HC595N for serial in and parallel out. So in this article, you will learn how to increase or expand outputs ports of Arduino using a simple shift register. This shift register IC74HC595N needs three input pins from Arduino and it give eight output pins, these extended pins are only used as output ports and operate or connect only the output devices like any LCD display, Buzzers, speakers, LED’s etc. For example, if you want to interface multiple seven segment displays with Arduino, you will surely face the issue of less output ports. So you can easily use this method to resolve this issue of falling short from output pins .
Introduction of 74HC595N Shift registerÂ
IC74HC595N is a shift Register is a 8-bit storage register and also 8-bit shift register with 8 bit serial inputs and 8 bit serial or parallel outputs also have 100MHz shift out frequency in which have storage register with 3 state output. In which the data is written to shift register in serial way and then latched into storage register and that register have controlled 8-output lines.
The shift register IC74HC595N hold what can be thought of an 8 memory position each can be a 1 or 0. To set out these values on or off mean 1 0r 0 then feed into the data by using the Data and Clock ports which is on the chip of IC shift register. The clock pin need to receive 8 pulses than at time of each pulse if data pin is active high then 1 gets pushed towards the shift register otherwise it is a 0. When all 8 pulses received then enable the Latch pin copies these 8 values to the latch register. This is essential otherwise the wrong output devices would starting as the data was being loaded into the shift register. The chip also an OE output enable pin which is used to enable or disable the outputs at once. Than attach this to the PWM pin of Arduino and use a command in program analogWrite to control the brightness of the output devices which is connected on the output port. When the pin is active low so tie it to GND.
Application: Embedded Design and Development, clock and timing, Consumer Electronics
Process of Extending outputs ports of ArduinoÂ
When Arduino merge the data and transmit the data to the device which is in serial format and that serial data to the shift register IC 74HC595N. And that shifted serial data is available to the output pins of shift register IC.
Example of how to increase output ports of ArduinoÂ
So now lets see with an example that how to expand output ports of Arduino using a simple shift register. We will connect eight light emitting diodes with Arduino through a shift register and try to control these LEDs with the help of Arduino and shift register. In this example, let take eight LED’s as a output device and connected to the output pins of shift register IC 74HC595N
Lets start with code which is about to control the 8 LED connected to the output ports.
 // these pins are define in the datasheet of shift register IC Int DS_pin = 8 ;          // means DS pin of IC connected to the pin 8 of Arduino Int STCP_pin = 9 ;      // means STCP pin of IC connected to the pin 9 of Arduino Int SHCP_pin = 10 :   // means SHCP pin of IC connected to the pin 10 of Arduino Void setup () { pinMode (DS_pin, OUTPUT) ;             // DS pin  are set to be outputs pinMode (STCP_pin, OUTPUT) ;         // STCP pin are set to be outputs pinMode (SHCP_pin, OUTPUT) ;         // SHCP pin are set to be outputs writereg () ;                          // declare function } Boolean registers [8] ;        // registers array Void writereg () { digitalWrite (SHCP_pin, LOW) ;       // start initialization the registers one by one for (int i = 7; i>=0; i--)                       // insert register value in the reverse order {                               // shift in the value that we have shored into the registers [8] array one by one digitalWrite ( SHCP_pin, LOW ) ;   digitalWrite ( DS_pin, registers[i] ) ;    // write the value of register digitalWrite ( STCP_pin, HIGH ) ;       // Creating LOW to HIGH transition here      } digitalWrite ( SHCP_pin, HIGH ) ; } Void loop () { For ( int i=0; i<9; i++)                  // within the for loop declare register high one by one { registers [i] = High ; Delay (100) ;                                  // time delay writereg ( ) ; } For ( int i=8; i>0; i++)                      // for reverse the leds { registers[i] = low ;                            // set to low Delay (100) ;                                     // time delay writereg ( ) ; } }                                                       // end the program
Now take a look at the circuit below which explain what actually going on. At the right the shift register IC 74HC595N and the connection which is from the Arduino. The GND and VCC of IC must be connect them with Arduino Board. The MR pin of IC must be at high mean connect to the VCC of 5v. In the datasheet of IC the the pin number 13 OE is the inverter pin so it must be grounded.Â
Figure 1. Hardware Circuit Diagram
Pins 8,9,10 of Arduino are connected to DS, STCP,SHCP pins of IC, these three pins of Arduino is a DataPin, ClockPin and LatchPin .
- DataPin: when serial data is need to transmit than used the DataPin.
- LatchPin: when there is a need to toggle
- ClockPin: when shift data is needed a clock pulse so it generated
- Also the output device LED connected to the IC pins from 1 to 7 and the 8th LED connected to Q0 pin which is at number 15.
Other method to increase output ports of ArduinoÂ
There is another way to get more output ports from Arduino. Now consider the Analog pins which is on the Arduino board as a digital output ports which is easier than that of above method. Let suppose that the analog pins from A0 to A5 is act like a digital output pins with number as 14, 15, 16, 17, 18, 19.
Example:
digitalWrite (15, LOW)
above write low the pin A1.