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

Interfacing a keypad with the RPZ


Now that we've looked at the Raspberry Pi Zero's pull-up and pull-down resistor options, we can apply our knowledge to operating a 12- or 16-digit keypad. Let's take a look!

Getting ready

All you'll need for this recipe is a 16-key numeric keypad. One is included in the Elegoo kit, and they are available from most online retailers. A typical keyboard input looks something like this:

How to do it...

  1. There are eight pins on a 16-key numeric keypad. Here is how you wire them to your Raspberry Pi:

  2. Understanding the internals of the keypad makes it easy to understand how to control it. Effectively, each number is a switch tied to a column and a row, as shown here:

    The Internals of a 16-key Input Pad

  3. Suppose we set our rows as inputs with the pull-down circuit enabled and configure the columns as outputs. Now, when a button is pressed, if we can detect which output and input were connected, we can determine which key was pressed. Look at keypad.py in the ch8 directory...