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 ...

Get Raspberry Pi Robotic Projects - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.