กลับไปหน้ารวมไฟล์
3-pins-32-leds-4-shift-registers-74hc595-09ae7d-en.md

This is a step-by-step guide that I have created for beginners and arduiNOOBS like me.

In this tutorial, we would be discussing some pretty basic knowledge about the 8-bit shift register called 74HC595. Learn how to daisy-chain them together and use some codes from an HC595 Library.

Also, I encountered a problem with some of the shift registers. I don't know why. Was it because of lack of power?


NECESSARY LINKS:

HC595 Library - https://github.com/j-bellavance/HC595

Datasheet - http://www.ti.com/document-viewer/SN74HC595/datasheet/specifications#SCLS0419845

More Information: https://rastating.github.io/using-a-74hc595-shift-register-with-an-arduino-uno/

For Loop Iteration: https://www.arduino.cc/en/Tutorial/ForLoopIteration


Social Media Links To Follow (I mean, if you want to):

Facebook - https://fb.me/HeathenHacks

Twitter - https://twitter.com/HeathenHacks

Instagram - https://instagr.am/HeathenHacks


Deep Daisy-Chaining: Shift Register Expansion

An Arduino Uno has 14 Digital pins. If you want to light up 32 separate LEDs independently (like for a massive LED cube or a flight-simulator dashboard), you physically cannot. This project introduces the foundational computer science concept of Serial-To-Parallel conversion, cascading to massively expand output limits using only 3 physical pins from the Uno!

Diagram

The Synchronous Cascade Protocol

The 74HC595 chip has 8 Output pins (Q0-Q7), but uses 3 Input pins (Data, Clock, Latch).

  1. The Daisy-Chain Physics: You physically wire the Q7' (Serial Out) of Chip #1 directly into the Data Pin of Chip #2!
  2. You tie all 4 Clock lines together, and all 4 Latch lines together. You now have a unified 32-bit hardware block!
  3. The Data Pipeline execution: To turn on LED #32, the Uno must physically pump 1 down the line. It goes into Chip 1. Then we push thirty-one 0s. The 1 is mathematically shoved exactly all the way down the electronic pipe into Chip 4, position 8!
It was a huge oversight on my part.
Initial Testing/Basic Setup
Before Wiring the LEDs.
Messy Wiring
LEDs
LEDs

The shiftOut() Register Bit-Masking

You cannot send decimal numbers trivially; you must use shiftOut().

  • The loop() uses a massive 32-bit unsigned integer (or four 8-bit Bytes)!
    uint32_t ledMatrix = 0b10000000000000000000000000000001; // Lights the FIRST and LAST LED!
    
    digitalWrite(latchPin, LOW); // Pause the physical output! Freeze the LEDs!
    // You must split the massive 32-Bit integer into Four 8-Bit chunks to send down SPI!
    shiftOut(dataPin, clockPin, MSBFIRST, (ledMatrix >> 24)); // Shift Chip 4!
    shiftOut(dataPin, clockPin, MSBFIRST, (ledMatrix >> 16)); // Shift Chip 3!
    shiftOut(dataPin, clockPin, MSBFIRST, (ledMatrix >> 8));  // Shift Chip 2!
    shiftOut(dataPin, clockPin, MSBFIRST, ledMatrix);         // Shift Chip 1!
    
    digitalWrite(latchPin, HIGH); // The shift is done! Violently blast the 32 LEDs on!
    
  • The execution is so unbelievably fast that it appears perfectly instantaneous to the human eye, enabling you to run huge Knight-Rider sweeping arrays seamlessly across all 32 LEDs!

Cascading Hardware Demands

  • Arduino Uno/Nano (Standard functionality).
  • Four 74HC595 Shift Register Integrated Circuits (DIP Packages).
  • 32 Red/Green/Blue 5mm LEDs.
  • 32 Generic 220 Ohm Resistors.
  • A 5V 3-Amp Power Brick (If you blast all 32 LEDs to maximum brightness simultaneously, the Uno's internal regulator will instantly crash!).
I encountered some odd problem with the shift registers with this particular number. "13CNONKE4".
Video Is Up!
CLICK HERE FOR THE BONUS LIGHT SHOW VIDEO! EDITED THE VIDEO IN PREMIERE, BECAUSE IT LOOKS PRETTY.
https://youtube.com/@HeathenHacks

ข้อมูล Frontmatter ดั้งเดิม

apps:
  - "1x Arduino IDE"
author: "Heathen_Hacks-v2"
category: "Tools & Equipment"
components:
  - "1x Arduino Nano R3"
  - "1x Jumper wires (generic)"
  - "1x LED (generic)"
  - "4x Shift Register- Serial to Parallel"
  - "1x Solderless Breadboard Full Size"
  - "1x Resistor 100 ohm"
description: "Infinite pin expansion! Annihilate the physical hardware limitations of the Arduino Uno by daisy-chaining multiple 74HC595 memory blocks, manipulating massive serial bit-shifting cascades to flawlessly command 32 independent LEDs."
difficulty: "Advanced"
documentationLinks: []
downloadableFiles:
  - "https://github.com/j-bellavance/HC595"
  - "https://github.com/j-bellavance/HC595"
  - "https://projects.arduinocontent.cc/602eb699-a8ab-482f-8084-2e761a04846f.ino"
encryptedPayload: "U2FsdGVkX19uBShQcKAFWD9nRtDkbdY75n5vWkMrzxtlARhWvdDIsa4JNzzGBQZJhFCtgFkWeV9n1hw1TArBm5QykE39APDjD90tdvKYp0E="
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/3-pins-32-leds-4-shift-registers-74hc595-09ae7d_cover.jpg"
lang: "en"
likes: 12
passwordHash: "f2b256cd57f479bdca1f89a5320081e2a50257dd0415305124763a4c8b5f990b"
price: 1120
seoDescription: "Learn to control 32 LEDs using 4 Shift Registers [74HC595] and 3 Pins. A beginner-friendly Arduino tutorial on daisy-chaining."
tags:
  - "lights"
  - "daisy-chaining"
  - "shift registers"
title: "3 Pins, 32 LEDs, 4 Shift Registers [74HC595]"
tools: []
videoLinks:
  - "https://www.youtube.com/embed/N7CAboD1jU0"
  - "https://www.youtube.com/embed/KXWsp9przuk"
views: 34734