Install Python I2C libraries

Your game needs a driver to read data from the bridge and send it to Scratch.  The driver consists of

  • Python script
  • Python Scratch library
  • Python I2C libraries

First, let's install the Python I2C libraries.  Open a terminal window by clicking on the icon (circled in red below) in the Raspbian top-bar menu.

Now execute the following commands by typing them into the terminal window and hit "Enter" after each line.  Installation verbiage will print to the screen for a few seconds after each command as the packages are installed over the internet.  Allow them to complete.

sudo apt-get install -y python-smbus
sudo apt-get install -y i2c-tools

Install the Scratch Python module

You’ll need to use “pip” to install the module that helps the Python driver to send data to Scratch.  Execute the following in your terminal window.

sudo pip install scratchpy

If you get a “command not found” error message, you’ll need to install Pip with the following commands:

sudo apt-get install python-pip

Then try to pip install scratchpy a second time.

Download Scratch Demo and Python Driver

Change your terminal window's working directory.  Execute the command

cd Desktop

then hit the "Enter" key on your keyboard.

Now, download the tutorial resources using Git.  Enter

git clone https://bitbucket.org/chipsnips/raspberrypibridge

If it worked, you should see download progress updates ending in with:

Unpacking objects: 100% ... done.

That's it! You are now be able to begin the Physical Computing with Scratch and Raspberry Pi tutorial.