Reader small image

You're reading from  Raspberry Pi Robotic Projects - Third Edition

Product typeBook
Published inOct 2016
Reading LevelBeginner
Publisher
ISBN-139781786467966
Edition3rd Edition
Languages
Concepts
Right arrow
Authors (2):
Richard Grimmett
Richard Grimmett
author image
Richard Grimmett

Dr. Richard Grimmett has been fascinated by computers and electronics from his very first programming project, which used Fortran on punch cards. He has bachelor's and master's degrees in electrical engineering and a PhD in leadership studies. He also has 26 years of experience in the radar and telecommunications industries, and even has one of the original brick phones. He now teaches computer science and electrical engineering at Brigham Young University, Idaho, where his office is filled with his many robotics projects.
Read more about Richard Grimmett

Jon Witts
Jon Witts
author image
Jon Witts

Jon Witts has been working within the IT industry since 2002 and specifically within Educational IT since 2004. He was introduced to Linux back in 2001 through his collaboration with two German artists who were visiting the arts organisation he was then working with. Having studied Fine Arts and Educational Technology and sought to innovate with open and accessible digital technologies within his creative practice, Jon is happiest when deconstructing technology and finding its limits. Jon has embedded within his school the use of Raspberry Pi computers, as an integral part of the delivery of the school's Computer Science curriculum as well as to run various school clubs and projects. Jon is a Raspberry Pi Certified Educator and also helps to organise and run the Hull Raspberry Jam events. I would like to thank my wife, Sally and our three daughters for putting up with all the cables and compoents around the house, and not least for being so tolerant of the need to dodge the robots racing round the kitchen floor!
Read more about Jon Witts

View More author details
Right arrow

Controlling the DC motors


To control the DC motors from the Raspberry Pi, you'll first want to install the libraries. Here are the steps to do so:

  1. cd ~: Go to the home directory.

  2. git clone https://github.com/simonmonk/raspirobotboard3.git : This command will get the library.

  3. cd raspirobotboard3/python: Go to the directory that has the installed files.

  4. sudo python setup.py install: Install the Python library.

Once these are installed, you can write this simple program to make the wheels go forward:

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

This should make the wheels go forward at half the speed. You can add a bit of code to check full speed and forward and backward:

#!/usr/bin/python 
from rrb3 import * 
import time 
rr = RRB3(11, 11) 
rr.set_motors(1, 0, 1, 0) 
time.sleep(1) 
rr.set_motors(0.5, 0, 0.5, 0) 
time.sleep(1)...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Raspberry Pi Robotic Projects - Third Edition
Published in: Oct 2016Publisher: ISBN-13: 9781786467966

Authors (2)

author image
Richard Grimmett

Dr. Richard Grimmett has been fascinated by computers and electronics from his very first programming project, which used Fortran on punch cards. He has bachelor's and master's degrees in electrical engineering and a PhD in leadership studies. He also has 26 years of experience in the radar and telecommunications industries, and even has one of the original brick phones. He now teaches computer science and electrical engineering at Brigham Young University, Idaho, where his office is filled with his many robotics projects.
Read more about Richard Grimmett

author image
Jon Witts

Jon Witts has been working within the IT industry since 2002 and specifically within Educational IT since 2004. He was introduced to Linux back in 2001 through his collaboration with two German artists who were visiting the arts organisation he was then working with. Having studied Fine Arts and Educational Technology and sought to innovate with open and accessible digital technologies within his creative practice, Jon is happiest when deconstructing technology and finding its limits. Jon has embedded within his school the use of Raspberry Pi computers, as an integral part of the delivery of the school's Computer Science curriculum as well as to run various school clubs and projects. Jon is a Raspberry Pi Certified Educator and also helps to organise and run the Hull Raspberry Jam events. I would like to thank my wife, Sally and our three daughters for putting up with all the cables and compoents around the house, and not least for being so tolerant of the need to dodge the robots racing round the kitchen floor!
Read more about Jon Witts