Raspberry Pi Projection Mapping using a Pi Cap
Learn how to use Raspberry Pi projection mapping to turn a simple graphic into an augmented reality super-wall, activated by touch
Taking inspiration from our community’s projects, we created a Raspberry Pi projection mapping tutorial using our Pi Cap, so more of you can have fun making interactive surfaces! If you want to make your project work wirelessly using WiFi, this is the tutorial for you.
For the projection, a computer connected to a projector runs some projection mapping software and Processing. For the Pi Cap-powered touch interface, a Raspberry Pi sends commands to Processing running on the computer via OSC, which in turn sends OSC commands to the projection mapping software, to trigger the projection.
We used MadMapper as our projection mapping software, but you can use other software if you prefer. You can download a demo version of MadMapper here. If you don’t already have a projector, check out this article for suggestions about which projector to use.
We think the Pi Zero W is the best for Raspberry Pi projection mapping, because it is small, compact, and offers integrated WiFi. If you don’t have a Pi Cap yet, check out our 5 Ways You Can Use Your Pi Cap here, or go and grab one from our shop.
To begin you will need:
Electric Paint 50ml
Electric Paint 10ml
laptop (or desktop computer) running MadMapper and Processing
Setting up the Pi Cap
If this is your first time using a Pi Cap, we suggest completing the tutorial on how to set-up your Pi Cap with a Raspberry Pi Zero first. In this tutorial, our Pi Zero is connected to our laptop via SSH which means we don’t need a keyboard or screen on the Pi itself.
Additionally, this project requires both Processing and OSC installed on the computer. Follow the Pi Cap + Grapher tutorial for a good introduction to both.
Prepare the animations in MadMapper
Touch commands will be sent to Processing via OSC and then to MadMapper to trigger two animations. Click here to download two sample animations.
Open MadMapper and drag and drop the animations into the workspace. Make sure to change the “Loop movie” setting to “Play the movie to the end of the loop and pause” so that the animation only plays once.
If you like, you can connect the projector to your laptop now and project the animations by going into “Full Screen Mode”.
Run the Processing code
Now you need to download the script that receives the OSC signals from the Pi Cap and sends another OSC signal to MadMapper. You can download this script here. To add our Pi Cap and MadMapper connection sketch to Processing, the picap_madmapper folder needs to be moved to the Processing Sketchbook Folder. This will be different for each operating system:
Libraries/Documents/Processing or My Documents/Processing
If this folder does not exist, you have to create it first.
On your Pi, run one of the “picap-datastream-osc” codes, including your laptop’s hostname. In Processing hit the run button. When you touch electrode 0 or 1 on the Pi Cap, it should play the respective animation in MadMapper. Gotta love OSC!
Paint the triggers
For the next step in our Raspberry Pi projection mapping tutorial, we need to start thinking about where we want to project the animation. We used some painted cardboard, which we attached to the wall. But you can use plywood, a blank canvas or paint directly onto a wall.
Next, we need to paint the graphics to start the animation using Electric Paint. You can paint the graphics either by hand, use stencils, or screen print. In this case, we simply painted a circle and square by hand.
Connecting to the Pi Cap
The next step is connecting the graphics to the Pi Cap. The Pi Zero has an advantage compared to the other Raspberry Pis because it is so small. As a result, you can attach our surface mount Pi Cap with the electrodes straight onto your project!
In the first place, turn your Pi Zero off and unplug it. If you are using a material where you can use the surface behind the graphics, for example with plywood or cardboard, then you can connect to the Pi Cap through the material. We used black nails, but you could also drill a hole and then use a screw, or some cable.
Then, to connect to the electrodes, you can use any conductive material, such as wires, copper tape or Electric Paint. We used copper tape, pierced it with black nails, and added a bit of Electric Paint on top to get a strong connection. Finally we cold soldered the Pi Cap to the tape using some more Electric Paint. To get a full overview on how you can connect to the sensors, have a look here.
Touch the paint and watch the animation
Now you’re ready for some Raspberry Pi projection mapping! After the paint has dried, connect your Pi Zero to power and run the OSC code. Then connect the projector to the laptop and run the Processing code. Touch the paint and watch the animation unfold!
If you look inside the code you can find the lines “mediasList = “bubble_animation.mp4″;” and “mediasList = “bubble_animation.mp4″;”. The number inside the square bracket corresponds to the electrode that is touched, so for example when touching electrode 0, MadMapper will play “bubble_animation.mp4”. If you want to use your own animation, you need to change the name in Processing. Therefore, if you want to include “animation1.mp4”, you need to include this filename in the Processing sketch, e.g. “mediasList = “animation1.mp4″;”.
If touching the Electric Paint doesn’t trigger the animation reliably, this might be because the distance between the Electric Paint and the Pi Cap is too long. To solve this, you could try changing the sensitivity of the Pi Cap’s electrodes, you can learn how to do this here.
We hope you have enjoyed our Raspberry Pi projection mapping tutorial. We would love to see what you make! Share your projects with us either via Instagram or Twitter or send us an email at firstname.lastname@example.org.