Arduino ShiftRegister74HC595 Library: Wiring, Code and Simulator

To build this Arduino ShiftRegister74HC595 Library project you need an Arduino Uno and a 74HC595 shift register and an LED bar graph. The ShiftRegister74HC595 library sets eight outputs of a 74HC595 in one call. Make the 23 connections in the wiring table, upload the Arduino C++ code, and use sr.set(pin, HIGH) to light one LED at a time.

Open this circuit in the free Arduino Uno simulator

Parts list

QtyPartWhat it does
1Arduino Unothe microcontroller board
174HC595 Shift RegisterDS data, SHCP shift clock, STCP latch; Q0–Q7 outputs. Tie OE to GND, MR to 5V, VCC to 5V, GND to GND. Use shiftOut().
1LED Bar GraphTen LEDs in a row: A1–A10 anodes, C1–C10 cathodes.

Wiring

#FromTo
1Arduino Uno pin 1174HC595 Shift Register DS
2Arduino Uno pin 1274HC595 Shift Register SHCP
3Arduino Uno pin 874HC595 Shift Register STCP
4Arduino Uno GND74HC595 Shift Register OE
5Arduino Uno 5V74HC595 Shift Register MR
6Arduino Uno 5V74HC595 Shift Register VCC
7Arduino Uno GND74HC595 Shift Register GND
874HC595 Shift Register Q0LED Bar Graph A1
974HC595 Shift Register Q1LED Bar Graph A2
1074HC595 Shift Register Q2LED Bar Graph A3
1174HC595 Shift Register Q3LED Bar Graph A4
1274HC595 Shift Register Q4LED Bar Graph A5
1374HC595 Shift Register Q5LED Bar Graph A6
1474HC595 Shift Register Q6LED Bar Graph A7
1574HC595 Shift Register Q7LED Bar Graph A8
16Arduino Uno GNDLED Bar Graph C1
17Arduino Uno GNDLED Bar Graph C2
18Arduino Uno GNDLED Bar Graph C3
19Arduino Uno GNDLED Bar Graph C4
20Arduino Uno GNDLED Bar Graph C5
21Arduino Uno GNDLED Bar Graph C6
22Arduino Uno GNDLED Bar Graph C7
23Arduino Uno GNDLED Bar Graph C8

Step by step

  1. Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Arduino Uno. No install or account is needed.
  2. Add the parts. Add a 74HC595 shift register and an LED bar graph from the parts palette.
  3. Wire 1. Connect Arduino Uno pin 11 to 74HC595 Shift Register DS.
  4. Wire 2. Connect Arduino Uno pin 12 to 74HC595 Shift Register SHCP.
  5. Wire 3. Connect Arduino Uno pin 8 to 74HC595 Shift Register STCP.
  6. Wire 4. Connect Arduino Uno GND to 74HC595 Shift Register OE.
  7. Wire 5. Connect Arduino Uno 5V to 74HC595 Shift Register MR.
  8. Wire 6. Connect Arduino Uno 5V to 74HC595 Shift Register VCC.
  9. Wire 7. Connect Arduino Uno GND to 74HC595 Shift Register GND.
  10. Wire 8. Connect 74HC595 Shift Register Q0 to LED Bar Graph A1.
  11. Wire 9. Connect 74HC595 Shift Register Q1 to LED Bar Graph A2.
  12. Wire 10. Connect 74HC595 Shift Register Q2 to LED Bar Graph A3.
  13. Wire 11. Connect 74HC595 Shift Register Q3 to LED Bar Graph A4.
  14. Wire 12. Connect 74HC595 Shift Register Q4 to LED Bar Graph A5.
  15. Wire 13. Connect 74HC595 Shift Register Q5 to LED Bar Graph A6.
  16. Wire 14. Connect 74HC595 Shift Register Q6 to LED Bar Graph A7.
  17. Wire 15. Connect 74HC595 Shift Register Q7 to LED Bar Graph A8.
  18. Wire 16. Connect Arduino Uno GND to LED Bar Graph C1.
  19. Wire 17. Connect Arduino Uno GND to LED Bar Graph C2.
  20. Wire 18. Connect Arduino Uno GND to LED Bar Graph C3.
  21. Wire 19. Connect Arduino Uno GND to LED Bar Graph C4.
  22. Wire 20. Connect Arduino Uno GND to LED Bar Graph C5.
  23. Wire 21. Connect Arduino Uno GND to LED Bar Graph C6.
  24. Wire 22. Connect Arduino Uno GND to LED Bar Graph C7.
  25. Wire 23. Connect Arduino Uno GND to LED Bar Graph C8.
  26. Paste the Arduino C++ code. Paste the Arduino C++ code below into the code editor.
  27. Run it. Press Run. Use sr.set(pin, HIGH) to light one LED at a time.

Arduino C++ code

// ShiftRegister74HC595 (Timo Denk): one 74HC595 (DS 11, SHCP 12, STCP 8) driving 8 LEDs.
#include <ShiftRegister74HC595.h>

ShiftRegister74HC595<1> sr(11, 12, 8);

void setup() {
  uint8_t pattern[] = {0b10110001};
  sr.setAll(pattern);
}

void loop() {}

What to try

Use sr.set(pin, HIGH) to light one LED at a time.

Frequently asked questions

How do I wire the ShiftRegister74HC595 Library project on an Arduino Uno?

Make 23 connections: Arduino Uno pin 11 to 74HC595 Shift Register DS; Arduino Uno pin 12 to 74HC595 Shift Register SHCP; Arduino Uno pin 8 to 74HC595 Shift Register STCP; Arduino Uno GND to 74HC595 Shift Register OE; Arduino Uno 5V to 74HC595 Shift Register MR; Arduino Uno 5V to 74HC595 Shift Register VCC; Arduino Uno GND to 74HC595 Shift Register GND; 74HC595 Shift Register Q0 to LED Bar Graph A1; 74HC595 Shift Register Q1 to LED Bar Graph A2; 74HC595 Shift Register Q2 to LED Bar Graph A3; 74HC595 Shift Register Q3 to LED Bar Graph A4; 74HC595 Shift Register Q4 to LED Bar Graph A5; 74HC595 Shift Register Q5 to LED Bar Graph A6; 74HC595 Shift Register Q6 to LED Bar Graph A7; 74HC595 Shift Register Q7 to LED Bar Graph A8; Arduino Uno GND to LED Bar Graph C1; Arduino Uno GND to LED Bar Graph C2; Arduino Uno GND to LED Bar Graph C3; Arduino Uno GND to LED Bar Graph C4; Arduino Uno GND to LED Bar Graph C5; Arduino Uno GND to LED Bar Graph C6; Arduino Uno GND to LED Bar Graph C7; Arduino Uno GND to LED Bar Graph C8.

What parts do I need for this Arduino project?

An Arduino Uno and a 74HC595 shift register and an LED bar graph.

Can I simulate this Arduino project online for free?

Yes. The BitForBytes Embedded Lab runs this exact circuit and Arduino C++ code in your browser for free, with no install and no hardware. The sketch is compiled with the real Arduino toolchain and runs on an emulated ATmega328P.

What does the code do?

The ShiftRegister74HC595 library sets eight outputs of a 74HC595 in one call.

More Arduino Uno projects