Pumpktris

What do you get when you combine a pumpkin with the classic video game Tetris? Pumpktris! Fully playable, embedded in a pumpkin, and with the stem serving as a controller. Watch the video below to see it in action, then read on for the development story.

The Idea

One of my habits is to write down all the crazy, fleeting ideas I have, then go back to review later rather than judging right off the bat, or even worse, forgetting them.  Earlier in the month I was looking through that idea notepad and found “Make Tetris Pumpkins” from sometime last year. My original plan had been to make forms to shape pumpkins into Tetris pieces as they grew, then stack them together for Halloween. Since Halloween was only a few weeks away and it was too late to start growing pumpkins, I thought “Why not make a pumpkin you can play Tetris on instead?”

I had a LOLShield I hadn’t assembled yet, and I knew that someone had already written Tetris for it, so I figured it would be a simple matter to poke some holes in the pumpkin to match the LEDs, make a controller, and be done. But oh no, that would be too simple, and would look kind of lame. Little tiny LEDs, all stuck together on a 2×3″ area? Nahhhh.

Plan B: Still use the LOLshield, but instead of mounting LEDs in the shield I would wire them up externally so I could space them out more on the pumpkin. Luckily, I didn’t get too far down that route before I realized that the bundle of wires between the LEDs and the shield would be as thick as my wrist and a nightmare to solder and organize.

I was going to have to make my own LED matrix and program my own Tetris. With the decision made, I ordered 140 amber LEDs from Mouser and a pair of LED Matrix I2C “backpacks” from Adafruit. These little circuits come with a mini (.8″ square) LED matrix that I could use for programming instead of having to wire up my own LED matrix right from the start..

Time to Solder

The first step was to make the LED matrix, and for that I’m grateful to have found this guide on hackaday.com to making a 70 LED matrix. My construction steps were essentially the same (plus 58 more LEDs), but I’ll go through them here anyway. For more theory, check out their post. Mine leans toward “what I did” rather than “why you should do it this way.”

It started with cutting 112 pieces of 2.5″ wire and 16 pieces of 8″ wire. The short ones would go between each LED, and the long ones would run to the controller. A cutting mat made it easy to quickly and accurately measure out the lengths.

Next I soldered seven short wires and one long one into a daisy chain. Then again 15 more times—one for each row and one for each column in the matrix.

A jig was needed for assembly, and here I differed from Hackaday. Instead of drilling hardboard, I opted to poke holes into 1/4″ foam-core board with an awl. It was a lot quicker than a drill would be, and the foam-core board had a little bit of give so that I could make the holes small and they’d stretch out to hold the LED securely while I soldered.

With a row of LEDS poked into holes, I tinned the base of each anode and clipped it short, then soldered the wire daisy-chain down the line. At each joint I slipped on a half-inch of heat-shrink tubing before soldering. I’m proud to say there were only a couple of times I forgot the heat-shrink and had to go back. What caused more trouble was being in a hurry and sliding the tubing down to the joint while it was still hot. It would start to shrink up and wouldn’t fit over the connection on the LEDs.

When eight rows of LEDs were finally strung together, it was time to mount them all into the jig and solder on the cathode columns. The procedure with the heat-shrink was the same. As each column was finished I would pull it out of the jig and fold it out of the way in order to reach the next column.

Check it out!  A finished LED matrix!

But guess what? That’s only one, and 8×8 isn’t enough room for a game of Tetris, so it all got done again! I’ll spare you a rerun on the pictures and description, but if you want to you can go back up and read it again to get the full experience.

The Adafruit LED Matrix Backpack is meant to have its LED matrix soldered right to the board, but instead I soldered on female headers that would permit me to plug in either the mini LED matrix for code testing or the large matrix for deployment. Someone will probably be along to tell me I need a resistor here or there or I’m going to blow some chip up—and they’re likely right—but it seems to have worked so far as-is.

To connect my own matrix to the I2C Backpack, I cut down a piece of prototyping board and soldered in the male headers, then connected the 8″ wires from the last row and last column of the matrix to the board.

Would it work, though? I needed some code in order to find out.

Code

I did all coding with the hardware mounted on my bamboo prototyping board. The mini matrices in the I2C backpack sockets fit on the desk much better than the big, floppy matrices I built would have.

There are seven Tetrominos—yes, that’s what they’re called—in the game. Each has four points, as implied by the “tetra” prefix. A three-dimensional array stores the location of every pixel of every shape, in each of four possible rotations. Storing each rotation is a lot easier (for my brain at least) than calculating it on the fly. As an example, here’s the T shape:

/* T */ {
 /* angle 0 */ { {0,1}, {1,1}, {2,1}, {1,2} },
 /* angle 90 */ { {1,0}, {1,1}, {2,1}, {1,2} },
 /* angle 180 */ { {1,0}, {0,1}, {1,1}, {2,1} },
 /* angle 270 */ { {1,0}, {0,1}, {1,1}, {1,2} } 
 }

To draw the active piece the program keeps an activePiece variable (the index of the shape in the array) and a rotation variable (the index of the rotation description of that shape), then offsets each pixel pair that it pulls out by a yOffset and xOffset of how far down the screen it’s moved and how far left or right.

It also keeps an array describing the status of each “fixed” piece. With every move of the active piece, whether by gravity or by user control, it checks against that fixed-piece array to see if the requested move can be made without a collision. If the forbidden movement is left, right, or a rotation, it simply doesn’t make the move. If the forbidden movement is vertical it considers the piece to have landed and writes the piece to the array of fixed pieces, then launches a new active piece. Along the way it keeps score, tracks the level, speeds up the drop of the active piece as the game goes on, etc.

You can download a copy of the code here. In order to use it you’ll also need to download the Adafruit LED Backpack library and Adafruit GFX libraries and install them on your computer by copying each to the “libraries” folder of your computer’s Arduino sketch folder.

The Wet Work

This project required the perfect arcade cabinet—errr, I mean pumpkin. It had to be tall enough that the eight-inch tall matrix wouldn’t wrap too far around the bottom or top, and it needed a nice straight stem. I bought 3 pumpkins in a row, thinking each was perfect until I got it home and realized one thing or another wouldn’t work. Finally I found what I needed and the other pumpkins were relegated to prototyping duty for practice drilling holes and cutting.

To get inside the pumpkin I cut a large opening on the back. It wouldn’t work to cut from the top because I wanted the controller up there, and it would be easier to put the LEDs straight in from the back rather than the top.

With a paper template taped on to the pumpkin, I poked guide holes through the orange flesh.

Once the holes were marked I drilled through with a 13/64″ bit.

And since round pixels just would not do for a proper Tetris game, I cut a square around each hole with an X-Acto blade. The ends of the holes on the inside of the pumpkin were left round.

To turn the stem into a joystick I carefully sawed the it off at its base and drilled a 1-1/8″ hole right where the shaft would pass through.

I squared off the inside of the pumpkin below the stem, cut down some drywall anchors so they wouldn’t poke through the pumpkin, and screwed them in. Later I would attach the joystick with short screws into the drywall anchors.

For a controller I used short handle joystick from SparkFun, with the red ball unscrewed and replaced with the stem of the pumpkin. I think I’m going to call this the  ”joystem” from now on, as disgusting as that may sound. I drilled a hole in the detached stem and epoxied in a 6mm bolt, then screwed that into a coupling nut on the joystick shaft.

One at a time, I started to poke each LED into its slimy place. It wasn’t long before a problem became apparent: there were 16 rows of holes on the outside, but only 15 on the inside. The angle that the holes were drilled toward the top of the pumpkin had the two rows coming together into a single row. I was eventually able to squeeze the LEDs past each other and direct them into their appropriate shafts. Once the LEDs were in, I attached the joystem.

I plugged each matrix into the I2C backpack and then that into the Arduino. Usually I’ll build a standalone bare-bones controller board, but since this was definitely not a permanent piece I used the Arduino board. Power was provided by eight rechargeable AA batteries.

It was time to play Pumpktris!

Everything worked great, except for some occasional glitches in the top matrix as the night went on. Maybe a power supply issue, but it’s also possible there might be some intermittent shorts that happen when you bury that many electrical connections inside a pumpkin. It’s also weird playing with the controller on the top and the display underneath, so if I were to do it again I would wire the joystem into a separate pumpkin, either wireless or with the wire made to look like a vine.

Next up? Porting Halo to a watermelon.*

By the numbers:

  • 128 LEDs
  • 256 pieces of heat-shrink tubing
  • 313 solder joints
  • around twelve hours of work over a week and a half
  • 9800-point high score so far

* No, not really.

UPDATE: I did a more in-depth writeup on how to make your own (as opposed to this story about how I made mine) at Instructables.

63 Comments on "Pumpktris"

  1. Ptolemy Runkel says:

    Nathan,

    Amazingly cool! Can’t wait to see what you do to your Xmas tree.

    – Ptolemy

  2. Cala says:

    This is absolutely amazing and I want one!!! This would be great fun for my store at Halloween. This perfectly represents one of my favorite video games paired with one of my favorite holidays.
    KUDOS!!!!! GOOD SHOW!!!!

  3. Matt says:

    Great work, & great write up too!

  4. t-bird says:

    Your idea for making square pixels of light from a round led is simply brilliant. Beautifully done.

  5. Audrey says:

    This is wicked cool! You should post this on Instructables too!

  6. Amazing… :-)

    (And I don;t say that about many Halloween related things).

    Thanks for sharing (and yes, Halo would be slightly more difficult..)

  7. Pino says:

    I wonder how long it’ll take for The Tetris Company to shut this down, given the precedent in Tetris v. Xio.
    http://www.wired.co.uk/news/archive/2012-06/20/tetris-clone-ruling

  8. k1ds3ns4t10n says:

    Very cool.. wireless mini pumpkin joystems would have been killer

  9. Sharky says:

    I think it does not violates the Tetris patent because it is not for a sale/resale or profit purposes. It is a fun only.

  10. Tone says:

    Nathan you make me want to go back to Radio Shack and assemble a few projects together. Great job. Helping to spread the news.
    http://www.sandboxworld.net/2012/10/pumpktris.html

  11. Geoff says:

    You win, good sir.

  12. Jerry S says:

    Man, You are way too cool!
    Thanks for the inspiration.
    I shared this page with my friends, so expect some well-deserved hits.

  13. RegorA says:

    You win for making pumpkin tetris, but you score a flawless victory for having a Beagle Bros. floppy envelope in the prototyping pic.

    • Nathan says:

      Thanks! That one is a sticker, and somewhere around here I’ve got one of the old PEEK & POKE posters I need to hang up.

  14. John says:

    Very VERY cool. The idea, the execution, all amazing. But…Is that a Beagle Brothers Software logo I see in the picture of the prototype? Where did you find THAT!

    • Nathan says:

      It is! It’s a sticker I found in my stash of old Apple ][ books and was scanning it in so I could make myself a t-shirt. I loved the Beagle Bros and tried out all of the PEEKs and POKEs they shared.

    • Nathan says:

      Good eye! It’s a sticker I found in a box of my old Apple ][ manuals. Always nice to find another fan of the old-school stuff!

  15. Denis says:

    “Tetromino”, not “Tetronimo”. Tetronimo is what you shout when you’re exited — “Tetronimo!”. Tetromino is like a Domino, only with four squares.

  16. michie says:

    what was your cost on it?

  17. Amazing, absolutely briliant idea… Great works.. :)

    I like you use the stem as joystick,

  18. Paul says:

    This is really cool! Could you publish the code source? I’m curious to see how it works.

    • Nathan says:

      Thanks Paul. Let me clean up and comment the source code a little and then I’ll add it here. I’ll send you a note when I do.

  19. amélie says:

    Awesome! the leds and concept is great and the joystick is an incredible feature.
    you rock!
    A. from France

  20. Oreo says:

    Awesome job.

  21. Olivier Mengué (dolmen) says:

    For next year you could connect the game to the net so that you neighbour can play too with their mobile phone. The Blinkenlights project may have some code useful for that task.
    http://blinkenlights.net/arcade

  22. Ritchie Williams says:

    Would have been nice to dip in wax to preserve a bit longer. Another suggestion is to mount it in a realistic molded foam pumpkin.

  23. tomatopipps says:

    This is awesome.
    Also, in reply to Pino, they can’t do a lawsuit, because this game is entirely different.
    Tetris is 10×20, and this is 8×16.

  24. tazvok says:

    Is there a reason you used clear LEDs as opposed to the diffused ones. The diffused LEDs would be easier to look at in my opinion though not as bright

    • Nathan says:

      Brightness was my first priority. If I’d had more time (and money to spend on it) I would have gotten samples of a few different kinds and tried them out.

  25. Aly Keller says:

    Nice super job.

  26. We are truly in awe of your wonderful creation. Are you selling these?

  27. Yvetta says:

    OMG – my thumbs are aching to play!!! That pumpkin is absolutely awesome…SO COOL!

  28. Hari says:

    Simply superb. Loving this idea…

  29. Noah W says:

    Hey, your pumpktris is awesome – you should post this as a step by step Instructable. I’m an editor on the site, we’re running a big Halloween Contest, and I think you’ve got a great entry here.

    If you have any questions, please don’t hesitate to ask.

    Again, really nice work.

  30. Eroc says:

    The colored LED’s just have a higher viewing angle, clear LED’s are diffused in their lens but typically their viewing angle peakes out around 70. If you want them less bright its better to just turn down the current, I don’t think the colored LED’s would do anything. What micro did you use?

  31. Dave O says:

    Just about the neatest Halloween thing I have seen, really cool!

  32. Dave O says:

    BTW, the Beagle Brother’s Software thing is classic, thanks for bring that and other stuff from my past to the front with this wonderful project!

  33. Jeannie says:

    Since there are now plastic foam pumpkins, it IS possible to make a perennial Pumpktris! What a great plan, and execution!

    • Nathan says:

      I considered using a foam pumpkin–and even bought one to start with–but decided that at least for this first version it would need to be in a real one.

  34. KaiserSoce says:

    I’d just like to point out, since apparently Nate was too humble, that he actually re-speckle-pattern’d the base of the joystem. This project is already mind blowing…but, it’s attention to details like that which take it to a whole new level. Amazingly well done!!

  35. JTHormel says:

    Make this, using one of those craft pumpkins…then you can play it all year long.

  36. Rik says:

    Pure imagination, great job!

  37. Matt Newman says:

    You should do a kickstarter project (on kickstarter.com) over the next year to get pre-orders. I bet you could get a lot of people to fund a project like this. If you don’t do it, I might be interested in helping raise money and hiring people to build them. Thoughts?

  38. JillFarrow says:

    Seriously fun and so geeky! Your creativity and attention to detail rock, Nathan!

  39. Sam Mc Kee says:

    You could use a Raspberry Pi to make a laptop pumpkin. With wifi.

  40. anse mist says:

    Nathan, this is just a great idea – and U had the brains to make it happen, too! Congrats!!
    We enjoyed the video so much!

  41. Cataptra says:

    Why not use a FOAM pumpkin, like a Funkin? They come in all sizes and it would not rot, so you could use the game every year or all year long. At least that is what I would have considered over a real pumpkin. Just my opinion.

  42. Maddy Mels says:

    Wait… wouldn’t the pumpkin rot after a couple of weeks?

  43. colin says:

    Guys this is a tip from someone who’s working on there own pumpkin right now. Don’t try making your own led matrix unless you want to die. try looking into strings of led lights, (string led) its the kinds used for Christmas trees.

  44. colin says:

    I want to take that comment back I don’t even know why I said something so ridiculous. cant build a matrix with christmas lights.

  45. Dave says:

    Love this project and thinking of remaking it for Halloween (I know got to get my ass in gear!) The LED Matrix from Adafruit is out of stock but do you have any other suggestions of what I could use? Thanks

  46. Érica Moreira says:

    I’d like to have your e-mail please, so that you could help me with this project.

    I’m just a student so i don’t understand a few things and i was hoping you could answer a few questions and give me a few tips :) .

    Thank you for the attention.

Trackbacks for this post

  1. Pumpkin Tetris inspired by our own LED Jack-o-lantern - Hack a Day
  2. MAKE | Pumpktris, Tetris-in-a-Pumpkin
  3. Play Tetris on this Pumpkin #electronichalloween « adafruit industries blog
  4. 20 Arduino projects of 2012 | Nudatech

Got something to say? Go for it!