Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Use a Touch Sensor to make an Interactive Box of Live Spiders!
This tutorial walks you through the process of connecting a Capacitive Touch Sensor Hat to Spacebrew and visualize the message in Unity. The project was done on MacOS. This tutorial will walk you through how to install the Cap Hat on your Raspberry Pi, have it send messages to Spacebrew, and receive Spacebrew messages in Unity.
- Terminal for Mac
Step 1: Solder the Sensor chip to the Raspberry Pi
- Instead of soldering them directly to each other, solder a set of header pins to the sensor so it's not a p permanent attachment.
- Attach the Cap Hat to the Pi
Step 2: Connect the Raspberry Pi and set it up
- Perform the software steps on Adafruit page: https://learn.adafruit.com/mpr121-capacitive-touch-sensor-on-raspberry-pi-and-beaglebone-black/software
- Download the MRHT folder
Step 3: Organise the folders on your Pi
- Log in to your Pi
- Navigate to the
- Copy the folder
- Make sure
pySpacebrewis also in
Adafruit_Python_MPR121 > Python > examples
Step 3: Run the test of the sensor
Adafruit_Python_MPR121 > examplesby entering
sudo python simpletest.pyin terminal.
- You should see the result printed in the console when you touch the different touch pins
- Download and place caphat_pub.py into
Adafruit_Python_MPR121 > Python > examples.
caphat_pub.pyin terminal to confirm it's working. Tap on pin 0 and it should look like this:
Step 4: Download and run the Unity file
- Download the Unity project from here.
- Open the scene
- We have one publisher:
buttonPressthat is triggered when the sensor detects a touch on pin 0
- We have two subscribers:
spawncorresponds to the function
spiderLaunch()which makes new spiders.
toggleCapsulecorresponds to the function
spiderWalk()which makes the spider walk using the
Step 5: Putting it together in Spacebrew
- From the Spacebrew server page, link your Raspberry Pi publisher (here named
MRHT_Light_Button) to both the Unity subscribers
Step 6: Putting it together in real life.
- Take an alligator clip, clip one end to pin 0 on the hat, and the other to a gross conductive material of your choice.
- Slip gross thing inside a box, make your friends touch it and watch them squeal in disgust!