Book Image

Raspberry Pi Zero Cookbook

Book Image

Raspberry Pi Zero Cookbook

Overview of this book

The Raspberry Pi Zero, one of the most inexpensive, fully-functional computers available, is a powerful and revolutionary product developed by the Raspberry Pi Foundation. The Raspberry Pi Zero opens up a new world for the makers out there. This book will give you expertise with the Raspberry Pi Zero, providing all the necessary recipes that will get you up and running. In this book, you will learn how to prepare your own circuits rather than buying the expensive add–ons available in the market. We start by showing you how to set up and manage the Pi Zero and then move on to configuring the hardware, running it with Linux, and programming it with Python scripts. Later, we integrate the Raspberry Pi Zero with sensors, motors, and other hardware. You will also get hands-on with interesting projects in media centers, IoT, and more.
Table of Contents (17 chapters)
Raspberry Pi Zero Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Connecting the 74HC595N shift register to control many LEDs


So far, we've been controlling LEDs with individual GPIO pins. Not only is this a rather inefficient use of the Raspberry Pi Zero GPIO, but even if we used every single available pin for an LED, that would be a pretty boring light show. Instead, by adding in an LED driver such as the inexpensive 74HC595N, you easily get the ability to leverage several LEDs, or multiple 4x7-segment-number displays. In this recipe, we will use the SPI interface to control an eight-LED array. Let's get cooking!

Getting ready

Here is what you'll need for this recipe. At this point, you should be able to improvise with LED options. I used the 74HC595N, which is a commonly available chip online and also included in Elegoo's Super Complete Starter Kit.

  • Eight 330 Ohm resistors

  • One 74HC595N LED driver

  • Eight LEDs, any color you want

  • Jumper cables, breadboard, cobbler

  • We will also be using the PiShiftPy library, available on pip:

          sudo pip install PiShiftPy
    

How...