Always wanted to shoot foam missiles with your Raspberry Pi, but didn’t have a automated build system handy to trigger it? Would you rather drag blocks in Scratch to make programs to attack your foes?
Introducing Scratch Retaliation!
Extending the Retaliation idea used in Raspberry Pi Retaliation, this program allows you to use the Scratch programming language to create programs on the Raspberry Pi to control a Dream Cheeky rocket launcher.
One of the first things my son asked after getting the Raspberry Pi Retaliation setup at home was whether we could write a program to control the missile launcher from Scratch. As it turns out, with a little bit of Python coding this isn’t hard to do at all! See below for instructions on how to get your own Scratch Retaliation setup.
- Raspberry Pi
- Dream Cheeky missile launcher
- Powered USB hub
Step 1 - Install pyusb:
The python-usb yum module is not new enough to work with the retaliscratch code. Instead download the source for 1.0 from pyusb.
Untar into a directory, then install pyusb with:
# sudo python setup.py install
Step 2 - Download retaliscratch:
# wget https://raw.github.com/cognitivegears/retaliscratch/master/retaliscratch.py # chmod +x retaliscratch.py
Step 3 - Install scratchpy
First, install pip for python:
# curl http://python-distribute.org/distribute_setup.py | sudo python # curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | sudo python
Then install scratchpy
# sudo pip install scratchpy
Step 4 - Download the example Scratch program
Step 5 - Connect and test
Connect the missile launcher (I used a powered USB hub) and test with a command such as
Load the example.py in Scratch and if needed enable remote sensor connections by clicking on “Sensing”, then right clicking on the X sensor value block and choose “enable remote sensor connections”.
Click the green flag and test by clicking on the Scratch sprite.