DIY LabVIEW Crew Documents

Showing results for 
Search instead for 
Did you mean: 

Crowd-sourced Internet Snacking with LabVIEW, LEGO Mindstorms NXT, and Twitter

How to Use LabVIEW, LEGO Mindstorms, and Salvaged Objects to Win an Internet Contest and Get Free Popcorn Go Viral!

My friend Dave Britt & I built a Twitter-powered popcorn machine for Fireworks Popcorn's Creative Pop 2010! Video Challenge contest. Dave built the hardware using a bunch of random bits from around his shop, and I provided the software design and the control program & hardware integration.  We didn't have a lot of time to pull this together, given that we each have real jobs, so it was important that both the hardware and software be built from readily available parts (e.g. software & hardware we both had lying around).  That meant doing the simplest thing that could possibly work.

Here's our video entry:

The Hardware

There are four primary pieces of hardware in the system:

  • A hot-air popcorn popper from Wal-Mart.  (side note: hot-air popcorn tastes like cardboard and I do not recommend popping corn this way except to win Internet Contests.)
  • An Archimedes' Screw to move kernels from the feed hopper to the popper in a controlled way.
  • A LEGO Mindstorms NXT (with one motor) that drives the screw, that moves the corn, that falls in the popper, that makes the snack, that feeds the people.
  • My MacBook Pro, running LabVIEW 2009 in Windows via Parallels and communicating with the NXT via USB.  I could have done this in LabVIEW on the Mac side, I suppose, but I prefer to work in a virtual machine.

After I had prototyped the motor control, I gave Dave my NXT set to play with.  I was then able to write the Twitter side of the software while he built the hardware.

The Software

The software consists of a LabVIEW program that monitors Twitter for the #popcorn hashtag and controls the NXT.  When new #popcorn tweets are found, the program initiates a motor move to dispense an amount of corn relative to the number of tweets retrieved (i.e. more #popcorn tweets means more popcorn delivered to the popper).  There's some minor magic in there related to extending an in-progress move if more tweets come in while a dispense is already in progress, but that's the basic gist of it.

In keeping with the "simplest possible thing" criteria, the software stitches together a few pre-existing (or nearly-pre-existing) technologies:

  • The free JKI State Machine provides the main logic loop of the program.  It goes without saying that I'd love the JKI State Machine, but this is a great example of the reason I love it -- it provides a ready-made template for a string-based queued state machine that makes it easy to prototype things quickly, then expand on and iterate the software easily.  And best of all, it's free.
  • Control of the NXT is provided by the LabVIEW Toolkit for LEGO Mindstorms NXT.  I am by no means an NXT jockey, so it made more sense to work entirely in LabVIEW.  In fact, there is no code actually running on the NXT in this system.  The motor is controlled directly by the LabVIEW program, which basically uses the NXT as a motor controller rather than as an independent piece of the puzzle.
  • I wrote some custom code to use the Twitter Search API, starting from Ton Plomp's example code on LAVA (which was in turn based on Christian Loew's example here).
  • To parse the Twitter results, I used JKI's awesome EasyXML Toolkit for LabVIEW.  Ton's example used this, too.  (Note: The demo version of EasyXML is free, too!)

The Video Production

We assembled everything in one evening at my house, and took the video.  Our video setup is pretty embarrasingly ghetto.  Dave had a digital camera with some sort of video features, and so we used that.  The lighting was just whatever was available in my dining room, and the audio was via the built-in mic on the camera.  Having worked a lot with Michael Aivaliotis of (he's also my JKI colleague!) I know the value of having good video and audio gear, but we were able to get some great footage with just what we had lying around.

Dave edited everything together with whatever video editing stuff is shipped with Windows Vista / Windows 7.  We probably should've used iMovie, but we were under a time crunch and the footage was on Dave's camera, so the simplest thing was to hack it up with whatever Windows gave him.

The Results

The results surpassed all expectations.  We did, in fact, win the contest, which was the original goal.

But not only that!  A couple days after posting the video it was picked up by some major online news sites, went viral, and subsequently spread around the world.  You can read more details on The JKI Software Blog.