Register your Account

Sign Up with us and enjoy!

A password will be e-mailed to you.

How the Pinata Buster Works

Posted October 27, 2010 in

If you haven’t played the Pinata Buster you can do that here.

The Pinata Graveyard

Rhett and I created the pinata buster as a fun example that showcases the security camera and interface. A few friends have asked me how the pinata buster works, so here’s an overview of how we hacked together this demo.

Two Systems
The Pinata Buster can be better understood if we divide it into two systems. The first system makes it possible to see and hear the pinata buster. This system includes the security camera that records video and the web browser interface for interaction. We will call this the security camera and interface. The other system is all the magic (i.e. swinging the stick, playing the music, and updating the monitor) that happens when the user clicks Bust Pinata. We’ll call this part ‘The Busting Machine’.

Serving live video over the internet
The security camera and interface system is super simple to set up. Plug power into the camera and connect it to the internet. Point and shoot. We slightly changed the interface for the pinata buster. We won’t talk more about this part because how it works exactly is a trade secret.

The Busting Machine
When Bust Pinata is clicked our server locks out others from hitting the pinata and then does a http request to a web server running on the computer that controls The Busting Machine (The Busting Computer). The http request

agent.get('http://localhost:7777/cgi-bin/' + usernick)

runs this perl script from cgi-bin:

#!/usr/bin/perl -w

my @values = split(/&/,$ENV{'QUERY_STRING'});
foreach my $i (@values) {
    ($varname, $mydata) = split(/=/,$i);

open (MYFILE, '>/home/rhett/usernick');
print MYFILE $mydata;
close MYFILE;
system('/home/rhett/music_player.rb &');
system('/home/rhett/servos/phidgets-examples/AdvancedServo-simple &');

The script has to do three things:

  1. Swing the stick
  2. Update the monitor
  3. Play music

Swinging the stick

We built this part with a wheelchair and a servos on a control board. We took the wheelchair dismantled most of it and mounted it on it’s side to a coffee table. Car hauler straps keep the wheelchair firmly connected to the coffee table. The coffee table is weighed down by the two big batteries that power the wheel. The whacker can go full speed without any wobbling. Connecting the stick to the wheel proved to be the hardest physical problem. We tried many complicated ways to tie the stick to the wheel. We tried a lot string in a intricate arrangement of sailor knots. We tried loads of duct tape. We tried sailor knots and duct tape. The solution we use now holds up as well as the intricate sailor knots but takes much less time to set up. Now we just use a single length of rope in between two screw ties.

Thats a machine that can whack a pinata pretty good, but we need to command it with a computer. We thought about reverse engineering the logic signal that was sent to the speed controller, but that seemed like a little bit of overkill for what needed to be done. Instead we built a small control board to pull the joystick forward. We pressed mounted a servos and screwed in the wheelchair’s control arm to a piece of poplar wood. We screw tied a braided string to the joystick and tied the other in to the servos. The servos was bought from Phidgets which provided us with a C API and example code. Using that we were able to write a simple C program that pulls the joystick for 5 secs then releases it.

Updating the monitor

The monitor is showing a webpage on the localhost served by the web server running on The Busting Computer. The webpage has javascript that is always pulling the name from a file.

   setInterval(function() {

$.ajax({ url: "http://localhost/cgi-bin/", context: document.body, success: function(data){

Here is the script used in the above code:

#!/usr/bin/perl -w

use CGI qw( :standard );
use CGI::Carp qw( fatalsToBrowser );

print header;

open( FILE, "< /home/rhett/usernick" ) or die "Can't open $filename : $!";
while(  ) {
close FILE;

You can see that this javascript is pulling the name from the file /home/rhett/usernick, which is updated by the first perl script. Here is the line of code that updates that file:

system("echo '$mydata' > /home/rhett/usernick");

Playing the music
This is pretty easy we have 4 different Mexican Hat Dance songs. We randomly choose one and play it with the shell command mpg123-alsa.

music_files = ['2.mp3', '3.mp3', '4.mp3', '5.mp3' ]

index = rand 4
chosen_file = music_files[index]
`/usr/bin/mpg123-alsa /home/rhett/pinata_music/#{chosen_file}`

Building an real world internet game
The idea for the pinata buster came because we wanted to build a cool demo to show off our awesome product. It was a lot of fun to build and play. There are an infinite number of different interactive games you could build that would be cooler. I think it would be cool if people started building more of these. If you have any ideas for a cool interactive game comment below or better build it.


1 Comment
  1. Nice project. For an alternative tunneling method to make accessible arbitrary (Web) services running on your PC or embedded system check Yaler and YalerTunnel on


Leave a Response

If you have a question or comment, or just need to get in touch, please use the form below.