Skip to content

Latest commit

 

History

History
96 lines (70 loc) · 1.99 KB

File metadata and controls

96 lines (70 loc) · 1.99 KB

CustomHC595

Arduino library for controlling HC595 shift registers with support for cascading multiple chips.

Features

  • Template-based design for any number of cascaded chips
  • Simple and intuitive API
  • Efficient buffer management
  • Zero runtime overhead

Installation

Arduino IDE

  1. Download from Releases
  2. Sketch → Include Library → Add .ZIP Library
  3. Select the downloaded file

PlatformIO

lib_deps = https://github.com/Studentul404/CustomHC595.git

Quick Start

#include <CustomHC595.h>

// Single chip (8 outputs)
CustomHC595<1> sr(8, 11, 12); // latchPin, dataPin, clockPin

void setup() {
  sr.write(0, HIGH);  // Turn on output 0
}

void loop() {
  sr.write(0, LOW);
  delay(500);
  sr.write(0, HIGH);
  delay(500);
}

Multiple Chips

// 4 chips = 32 outputs
CustomHC595<4> sr(8, 11, 12);

void loop() {
  // Control any output from 0 to 31
  sr.write(15, HIGH);
  sr.write(31, LOW);
}

API

Method Description
begin(latch, data, clock) Initialize pins
write(num, state) Set output state (0 to N*8-1)
setAll() Turn on all outputs
clearAll() Turn off all outputs
update() Manually refresh outputs
amount() Get total number of outputs

Wiring

Arduino → HC595
Pin 8   → ST_CP (Latch)
Pin 11  → DS    (Data)
Pin 12  → SH_CP (Clock)
5V      → VCC
GND     → GND

Cascading: Connect Q7' of first chip to DS of next chip. All chips share latch, clock, VCC, and GND.

Stability tip: For reliable operation with multiple chips or long wires, add 0.1µF capacitor between VCC and GND of each chip.

Examples

Check examples/ folder for:

  • BasicUsage - Single chip demo
  • MultipleChips - Cascaded chips demo

License

MIT License - see LICENSE file

Links