Browse over 10,000 Electronics Projects using the Page Numbering provided at the bottom of each Page.

74HC165 8 bit Parallel in/Serial out Shift Register

74HC165 8 bit Parallel in/Serial out Shift Register

Previously, I’ve made a tutorial on how to use a 74HC595 Serial In/ Parallel Out Shift Register, which is useful in expanding output pins. In this tutorial, I am going to show another shift register which is capable of expanding input pins. The IC that I am using is 74HC165 Parallel In/ Serial Out Shift Register. One of the advantages that need to be stressed on is that by using only four pins, I can get eight input pins. Moreover, it can be cascaded, thus you can have any amount of input pins with only four pins with the help of this shift register.

74HC165 Parallel in, Serial Out Shift Register

Some of the features of 74HC165:

  • 8 bit Parallel Input
  • Serial output
  • Can be cascaded/ daisy chained

For more details on the chip, please refer to the datasheet here.

74HC165 Pin Diagram

74HC165 Pin Diagram

Pin Description

Pin Description

The input pins of the shift registers are pin 11 to 14 (D0 to D3) and pin 3 to pin 6 (D4 to D7). The input voltage acceptable range is between GND to Vcc, where maximum allowable voltage for Vcc is 7V according to the datasheet. However, it is recommended to operate the chip at 5V. 74HC165 has two output pins which are Q7 and /Q7, where /Q7 is the complement (inverted) of Q7.

After discussing about the input and output pins, let us move on with the control pins. To control the shift register, you would need three pins which are parallel load input (PL), clock input (CP) and clock enable input (CE).

Another pin that is useful especially when you want to cascade a few shift registers together, which is Serial Data Input (DS). Schematic on how to cascade the shift register will be shown later on.

Now, let us look into detail how to use the shift register. Initially, you need to make the parallel load input high. A low signal will triggers the input to be loaded into the shift register. This gives you a flexibility when to read the input to the shift registers. Besides, you want to stop reading the inputs while serially sending the output.

Next, you need to send the clock pulse to the shift register in order to obtain the serial output. However, you would need to set the clock enable before clocking out the data. After the clock is enabled, the parallel input data will be sent out in eight clock pulses.

A summary of the shift register operation is shown is the timing diagram below.

Timing Diagram for 74HC165

Timing Diagram for 74HC165

A simple schematic showing how to connect your 74HC165 Shift Register to Arduino. Notice that I am using a pull up resistor of 10k ohm on all the inputs. You can can also change it into pull down resistor network connection.

Schematic for 74HC165

Schematic for 74HC165

To cascade between two 74HC165 shift register, all you need to do is to connect the Serial Output (Pin 9) of first stage into Serial Input (Pin 10) of the second stage. You can cascade a lot of shift register to get tons of inputs. An example application of cascading the shift registers to get more input is the Arduino Piano that I have made previously.

Cascading 74HC165 Shift Register

Cascading 74HC165 Shift Register

Some of the images of setup on a breadboard.

Circuit setup on breadboard

Circuit setup on breadboard

Connection from 74HC165 to DIP switches

Connection from 74HC165 to DIP switches

LCD Display the Shift Register Input

LCD Display the Shift Register Input

All Input goes low

All Input goes low

In order to ease the process of reading data from shift register, I am using an Arduino built in function which is ShiftIn(). More details regarding the function, please refer Arduino Reference.

ShiftIn(data,clock,order)

– The data is the input pin on Arduino to read the output from shift register whereas the clock is the pin connected to shift register clock. For the order, you can choose either MSBFIRST or LSBFIRST.

Note that you need to control the parallel load pin by yourself since it can’t be controlled by the shiftIn function. It can be controlled simply by digitalWrite to either HIGH or LOW.

Below is the code I used to test out 74HC165 Shift Register:

//shift register experiment
//coded by zxlee
//iamzxlee.wordpress.com

#include <LiquidCrystal.h>

LiquidCrystal lcd(6,7,8,9,10,11);

#define enable 2
#define load 3
#define clock 4
#define data 5

void setup()
{
lcd.begin(16,2);
pinMode(enable,OUTPUT);
pinMode(load,OUTPUT);
pinMode(clock,OUTPUT);
pinMode(data,INPUT);
digitalWrite(load,HIGH);
digitalWrite(enable,HIGH);
lcd.print("Input = ");
Serial.begin(9600);
}

void loop()
{
digitalWrite(load,LOW);
delayMicroseconds(5);
digitalWrite(load,HIGH);
delayMicroseconds(5);

digitalWrite(clock,HIGH);
digitalWrite(enable,LOW);
byte incoming=shiftIn(data,clock,MSBFIRST);
digitalWrite(enable,HIGH);

for(int i=7;i>=0;i--)
{
if(bitRead(incoming,i)==1)
{
lcd.setCursor((15-i),0);
lcd.print("1");
}
else
{
lcd.setCursor((15-i),0);
lcd.print("0");
}
}

}

Last but not least, a video demo showing the operation of 74HC165 Shift Register

 

 

Top




Shares