Controlling R2D2 using the Raspberry Pi in Python
The hardware is ready; now you can access all this functionality from the Raspberry Pi. First, install the library associated with the control board, found at http://www.monkmakes.com/rrb3/. Perform the following steps:
- Type
cd ~
. - Run the command
git clone
https://github.com/simonmonk/raspirobotboard3.git
—this will retrieve the library. - Then type
cd raspirobotboard3/python
to go to theraspirobotboard3/python
directory. - 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 motor to turn the top and/or light the LED. Here is that code:
#!/usr/bin/python import time import RPi.GPIO as io from rrb3 import * io.setmode(io.BCM) forward_pin = 27 backward_pin = 22 led1 = 24 led2 = 23 def forward(): io.output(forward_pin, True) io.output(backward_pin, False) def backward(): io.output(forward_pin, False) io.output...