Book Image

Raspberry Pi LED Blueprints

By : Agus Kurniawan
Book Image

Raspberry Pi LED Blueprints

By: Agus Kurniawan

Overview of this book

Table of Contents (14 chapters)
Raspberry Pi LED Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Introducing a shift register


If our project needs to control 32 LEDs, we would normally require 32 pins of a microcontroller (MCU). The problem is that every MCU has a limited number of pins for GPIO. To address this issue, we can extend our MCU GPIO pins.

One of the solutions to extend GPIO pins is to use a shift register. We can use 74HC595 to extend the GPIO output pins. If you want to extend the GPIO input pins, you can use 74HC165. The schema of 74HC595 can be seen in the following figure:

The Q0 to Q7 pins are the parallel output from the chip. The DS pin is the serial data. STCP is the latch pin, and SHCP is the clock pin.

In this section, you will see how to implement a shift register to extend Raspberry Pi GPIO output pins using IC 74HC595 (Sparkfun, https://www.sparkfun.com/products/733). We need eight LEDs for the demonstration. The program will turn on only one LED at a time. It starts from LED 1 to 8. The hardware wiring is shown in the following figure:

When the output enable...