Book Image

Getting Started with Raspberry Pi Zero

By : Richard Grimmett
Book Image

Getting Started with Raspberry Pi Zero

By: Richard Grimmett

Overview of this book

Raspberry Pi Zero is half the size of Raspberry Pi A, only with twice the utility. At just three centimeters wide, it packs in every utility required for full-fledged computing tasks. This practical tutorial will help you quickly get up and running with Raspberry Pi Zero to control hardware and software and write simple programs and games. You will learn to build creative programs and exciting games with little or no programming experience. We cover all the features of Raspberry Pi Zero as you discover how to configure software and hardware, and control external devices. You will find out how to navigate your way in Raspbian, write simple Python scripts, and create simple DIY programs.
Table of Contents (16 chapters)
Getting Started with Raspberry Pi Zero
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Controlling your mobile platform programmatically using the Raspberry Pi Zero


Now that you have your basic motor controller functionality up and running, you need to connect both motor controllers to the Raspberry Pi Zero. This section will cover this and also show you how to control your entire platform programmatically.

You are going to use Python in your initial attempts to control the motor. It is very straightforward to code, run, and debug your code in Python. The first Python program you are going to create is shown in the following screenshot:

Perform the following steps to create this program:

To create this program, create a directory called dcmotor in your home directory by typing mkdir dcmotor and then type cd dcmotor. Now, open the file by typing emacs dcmotor.py (if you are using a different editor, open a new file with the dcmotor.py name).

Now, enter the program. Let's go through the program step by step:

  • #!/usr/bin/python: This line lets you run the program without having to...