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
| Qty | Part | What it does |
|---|---|---|
| 1 | Arduino Uno | the microcontroller board |
| 1 | 74HC595 Shift Register | DS data, SHCP shift clock, STCP latch; Q0–Q7 outputs. Tie OE to GND, MR to 5V, VCC to 5V, GND to GND. Use shiftOut(). |
| 1 | LED Bar Graph | Ten LEDs in a row: A1–A10 anodes, C1–C10 cathodes. |
Wiring
| # | From | To |
|---|---|---|
| 1 | Arduino Uno pin 11 | 74HC595 Shift Register DS |
| 2 | Arduino Uno pin 12 | 74HC595 Shift Register SHCP |
| 3 | Arduino Uno pin 8 | 74HC595 Shift Register STCP |
| 4 | Arduino Uno GND | 74HC595 Shift Register OE |
| 5 | Arduino Uno 5V | 74HC595 Shift Register MR |
| 6 | Arduino Uno 5V | 74HC595 Shift Register VCC |
| 7 | Arduino Uno GND | 74HC595 Shift Register GND |
| 8 | 74HC595 Shift Register Q0 | LED Bar Graph A1 |
| 9 | 74HC595 Shift Register Q1 | LED Bar Graph A2 |
| 10 | 74HC595 Shift Register Q2 | LED Bar Graph A3 |
| 11 | 74HC595 Shift Register Q3 | LED Bar Graph A4 |
| 12 | 74HC595 Shift Register Q4 | LED Bar Graph A5 |
| 13 | 74HC595 Shift Register Q5 | LED Bar Graph A6 |
| 14 | 74HC595 Shift Register Q6 | LED Bar Graph A7 |
| 15 | 74HC595 Shift Register Q7 | LED Bar Graph A8 |
| 16 | Arduino Uno GND | LED Bar Graph C1 |
| 17 | Arduino Uno GND | LED Bar Graph C2 |
| 18 | Arduino Uno GND | LED Bar Graph C3 |
| 19 | Arduino Uno GND | LED Bar Graph C4 |
| 20 | Arduino Uno GND | LED Bar Graph C5 |
| 21 | Arduino Uno GND | LED Bar Graph C6 |
| 22 | Arduino Uno GND | LED Bar Graph C7 |
| 23 | Arduino Uno GND | LED Bar Graph C8 |
Step by step
- Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Arduino Uno. No install or account is needed.
- Add the parts. Add a 74HC595 shift register and an LED bar graph from the parts palette.
- Wire 1. Connect Arduino Uno pin 11 to 74HC595 Shift Register DS.
- Wire 2. Connect Arduino Uno pin 12 to 74HC595 Shift Register SHCP.
- Wire 3. Connect Arduino Uno pin 8 to 74HC595 Shift Register STCP.
- Wire 4. Connect Arduino Uno GND to 74HC595 Shift Register OE.
- Wire 5. Connect Arduino Uno 5V to 74HC595 Shift Register MR.
- Wire 6. Connect Arduino Uno 5V to 74HC595 Shift Register VCC.
- Wire 7. Connect Arduino Uno GND to 74HC595 Shift Register GND.
- Wire 8. Connect 74HC595 Shift Register Q0 to LED Bar Graph A1.
- Wire 9. Connect 74HC595 Shift Register Q1 to LED Bar Graph A2.
- Wire 10. Connect 74HC595 Shift Register Q2 to LED Bar Graph A3.
- Wire 11. Connect 74HC595 Shift Register Q3 to LED Bar Graph A4.
- Wire 12. Connect 74HC595 Shift Register Q4 to LED Bar Graph A5.
- Wire 13. Connect 74HC595 Shift Register Q5 to LED Bar Graph A6.
- Wire 14. Connect 74HC595 Shift Register Q6 to LED Bar Graph A7.
- Wire 15. Connect 74HC595 Shift Register Q7 to LED Bar Graph A8.
- Wire 16. Connect Arduino Uno GND to LED Bar Graph C1.
- Wire 17. Connect Arduino Uno GND to LED Bar Graph C2.
- Wire 18. Connect Arduino Uno GND to LED Bar Graph C3.
- Wire 19. Connect Arduino Uno GND to LED Bar Graph C4.
- Wire 20. Connect Arduino Uno GND to LED Bar Graph C5.
- Wire 21. Connect Arduino Uno GND to LED Bar Graph C6.
- Wire 22. Connect Arduino Uno GND to LED Bar Graph C7.
- Wire 23. Connect Arduino Uno GND to LED Bar Graph C8.
- Paste the Arduino C++ code. Paste the Arduino C++ code below into the code editor.
- 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
- Arduino LED Blink: Wiring, Code and Simulator
- Arduino LDR Light Sensor: Wiring, Code and Simulator
- Arduino NTC Thermistor Thermometer: Wiring, Code and Simulator
- Arduino PWM to Analog RC Filter: Wiring, Code and Simulator
- Arduino Capacitance Meter: Wiring, Code and Simulator
- Arduino DC Motor PWM Speed Control with MOSFET: Wiring, Code and Simulator