Book Image

Raspberry Pi Robotic Projects - Third Edition

By : Richard Grimmett, Jon Witts
Book Image

Raspberry Pi Robotic Projects - Third Edition

By: Richard Grimmett, Jon Witts

Overview of this book

This book will allow you to take full advantage of Raspberry Pi Zero and Raspberry Pi 3 by building both simple and complex robotic projects. The book takes a mission-critical approach to show you how to build amazing robots and helps you decide which board to use for which type of robot. The book puts a special emphasis on designing mobile (or movable) robots using the Raspberry Pi Zero. The projects will show inexpensive, yet powerful, ways to take full advantage. It will teach you how to program Raspberry Pi, control the movement of your robot, and add features to your robots.
Table of Contents (13 chapters)
Raspberry Pi Robotic Projects - Third Edition
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface

Controlling Wall-E's tracks using a Raspberry Pi in Python


The hardware is ready; now you can access this functionality from a Raspberry Pi. First, install the library associated with the control board, found at http://www.monkmakes.com/rrb3/. Perform the following steps:

  1. Type cd ~.

  2. Run the git clone https://github.com/simonmonk/raspirobotboard3.git—command this will retrieve the library.

  3. Then type cd raspirobotboard3/python to go to the raspirobotboard3/python directory.

  4. Type sudo python setup.py install—this will install the files.

Now you'll create some Python code that will allow you to access both the DC motors on your tracked platform. Here is some basic code that allows you to do this:

#!/usr/bin/python                                                               
 
import time 
from rrb3 import * 
 
rr = RRB3(9, 6) 
rr.set_motors(1, 0, 1, 0) 
time.sleep(1) 
rr.set_motors(0, 0, 0, 0) 
rr.sw1_closed() 

The lines of the code import the time...