74HC595 Shift-Register 8-LED Bar Graph

Three Arduino pins drive eight LEDs through a shift register — your first lesson in trading I/O lines for serial-to-parallel conversion.

Difficulty: Breadboard. Estimated build time: about 35 minutes. Estimated parts cost: about US$4.80. 5-line bill of materials. Compare supplier offers when available. An 8-LED bar graph driven through a 74HC595 8-bit serial-in / parallel-out shift register, controlled from just three Arduino pins (data, clock, latch).

Place the chip and power it

Drop the 74HC595 across the breadboard divider. Pin 16 → +5 V, pin 8 → GND. Decouple with 100 nF right next to the chip. Pin 10 (master reset, active-low) → +5 V to disable it. Pin 13 (output enable, active-low) → GND so the outputs are always live.

Wire the three control lines

Pin 14 (DS, serial data) → Arduino pin 11. Pin 11 (SHCP, shift clock) → Arduino pin 12. Pin 12 (STCP, latch / storage clock) → Arduino pin 8. These three Arduino pins replace eight LED pins — that is the whole point.

Wire the LEDs

The 74HC595's 8 parallel outputs are pins 15, 1, 2, 3, 4, 5, 6, 7 — corresponding to Q0 through Q7. Run each one through its own 470 Ω current-limiting resistor to its own LED's anode; tie all 8 cathodes to GND. The order is annoying — Q0 is pin 15, then Q1-Q7 are pins 1-7. Once you accept it, layouts get clean.

Write the firmware

In setup() set pins 11, 12, 8 as OUTPUT. In loop(), to display the byte b: digitalWrite(8, LOW); shiftOut(11, 12, MSBFIRST, b); digitalWrite(8, HIGH). The shiftOut() helper handles the bit loop. Try a counter that increments every 100 ms — you will see the LEDs light up in 8-bit binary.

Try a bar graph and a Knight-Rider chase

Bar graph: byte b = (1 << level) - 1; cycles through 0b00000001, 0b00000011, 0b00000111… up to 0b11111111. Chase: byte b = 1 << pos; pos goes 0..7..0..7 to bounce a single dot across the row. The same 4 lines of code can drive 8 LEDs, 16 LEDs (chain a second '595 on pin 9 → next chip's pin 14), or 64 LEDs across an 8x8 matrix.