Mint Tin Hero

A friend at work proposed a friendly competition between a few co-workers: to make something cool out of a Trader Joe’s green tea mint tin.  Anything – whatever our creative hearts desired.  The prize?  Nobody cared – we’d figure that part out later.

mint_tin

I thought it would be fun to do something electronic with it – maybe even squeeze an Arduino in there.  But it would be tough – the tin was pretty tiny.  And it had a clear plastic screen on the cover.  I had to figure out what to do with that…

After a night of brainstorming, and then another week or so of indecision, I settled on making a Guitar-Hero-like rhythm game, involving a single sensor, an LCD screen, and a small speaker for playing some cheesy music.  I play drums, and I was kind of thinking of the whole mint tin as a drum, with the plastic screen acting like a drum head.  The other side, made of metal, would host the LCD screen and speaker, facing the “player”.

(Product endorsement: Don’t worry about eating through all the mints before you start this project – they’re actually quite good…)

DSC_0007

Parts:

  • Arduino chip (ATMEGA328P), with an already-programmed bootloader (can rip out of an Arduino board, or purchase separately online)
  • Hitachi HD44780 compatible 8×2 character LCD module
  • 20 mm piezo disc w/ wires attached (bare, no plastic casing) (ebay is a good resource)
  • small 4Ω speaker w/ wires attached (taken from another device)
  • small 10 KΩ trimmer potentiometer (Jameco 1967512)
  • battery holder for CR2032 (Jameco 355434)
  • 2x CR2016 button cell batteries
  • small slide switch (Jameco 161817)
  • female headers (Jameco 308567) (will need 10 recepticles, but you need to cut these up – get extra)
  • 1 MΩ resistor
  • 2x 100 Ω resistors
  • solid-core wire
  • wire-wrap wire
  • small pieces of duct tape and clear tape
  • Trader Joe’s green tea mint tin

Tools:

  • Arduino board with the chip removed, used for programming the Arduino chip on the mint tin board
  • jumper wires
  • hammer / nail or something to puncture the tin
  • scrap piece of wood
  • nibbling tool (Jameco 18810)
  • good soldering iron / solder
  • hot glue gun / hot glue
  • wire strippers / snippers
  • “helping hands” soldering aid (not necessary, but recommended)

Schematic:

mint_tin_hero_schematic

Steps:

The schematic, Fritzing layout, and Arduino code can be downloaded here.

1. Solder some of the main components on the circuit board.

mint_tin_hero_layoutIt’s tough to cram all this stuff on a tiny PC board.  This project might test your soldering skills and/or patience.  But, as with many things, if you’re getting frustrated, it’s always best to walk away and come back later.  (I definitely had to do this a few times…) 

Anyway, if you take a look at the layout of the board, you’ll see that there are a lot of overlapping wires and such.  The red lines are the positive (~5V) wires, the black lines are the negative (0V) wires, the gray lines are the solder lines running on the underside of the board (where the little metallic circles are), and the other colors are just other signals.

(Note that some of the components in the diagram don’t perfectly represent the “real-world” parts – e.g. the LCD screen shown is a 16×2, rather than a 8×2, but bear with me…)

DSC_0005The easiest way to start off is to get some of the big components on there: the Arduino, the battery holder, and the switch.  Just dab some solder at the corners of the Arduino to hold it in place.  Make sure it’s oriented the way shown in the diagram.  

The power supply for this circuit is a bit of a hack.  Usually, you don’t want to run power directly from the batteries – normally, you’d want to have a 5V voltage regulator.  Instead, we’re hooking up an unregulated 6V supply (two 3V batteries) right to the digital circuit.  Blasphemy!  It turns out that the batteries actually don’t supply enough juice to support a voltage regulator, and the Arduino and LCD module can handle the 6V ok (actually more like 5.8V).  So, there you have it.  Sorry if I’ve offended anyone.

2. Cut up and attach the headers.

You will need to cut up some of the headers for use on the board.  You can cut them with wire snips – I would recommend just cutting directly through one of the holes, effectively “wasting” a hole between pieces.  You need 2 3-hole headers placed next to each other to make a 3×2 header.  This will be used for loading your code onto the Arduino later on.

The other 4×1 header, in the upper left of the diagram, is not necessary if you are using an Arduino chip with the bootloader pre-loaded on it (e.g. a chip pulled off of an existing Arduino board).  I was using a chip that did not already have the bootloader configured on it, so I needed this header to program it.

DSC_0006This part is a little tricky: to connect one component to another, you need to “drag” the solder around from hole to hole on the underside of the board.  This can be a little frustrating, and a “helping hands” tool definitely comes in handy here.  Try connecting the leftmost pins of the 3×2 header to the Arduino pins directly next to it.  I found that a good way to do this was to get a good amount of solder on both the Arduino pin and the adjacent header pin, and then put the soldering iron tip right between the two holes, and then lift straight up in order to leave a connecting line of solder between them.

3. Solder in most of the other components and wiring.

Using the technique described above, solder in the two resistors on the left side of the Arduino (a 1 MΩ and a 100 Ω).

Also solder in the wiring on the left side of the Arduino.  Hold off on the potentiometer for now (if you already put it on, it’s not a big deal).  The bottom of the board is a “ground line” – there is solder running across the length of the board, all connected to ground.  This will require a bit of dragging solder around.

The right side of the Arduino is a little tricky, because there will be will be some wires that DSC_0010extend through the board in order to connect to the LCD module.  When you strip these wires, leave a good inch or two of stripped wire poking out the back.  You will later need to thread all of these wires (and actually one resistor) through the holes in the LCD module.

There is one little “<” shown in gray in the diagram on the LCD pins that you may want to use wire-wrap wire for – see the potentiometer section below…

(NOTE: The image above and a few others in this post are not 100% accurate.)

4. Solder on and hook up the potentiometer.

I kind of screwed up when designing the board, and thought that I could get away with not using a potentiometer to control the contrast of the LCD screen.  In my original version, the screen ended up being way too dark to play the “Mint Tin Hero” game.  So, I put the little potentiometer in there as an afterthought.

Because the board is so tight on space, I think that even if I had originally planned on it, it would have been pretty difficult to wire up all the appropriate connections to the potentiometer.  So, I ended up using some very tiny wire-wrap wires to connect the potentiometer to where it needs to go: ground, ~5V, and the Vo contrast pin on the LCD module.

The output of the potentiometer needs to connect from a wire-wrap wire to a single solid core wire sticking through the board to the Vo pin of the LCD module.  This was a little tricky, and you might have to get creative with the wires and soldering here.

If you get past this part, you can consider becoming a surgeon.  Stripping the ends of the wire-wrap wire can be a little difficult.  I made little “hooks” with the stripped parts of the wire and hooked them around the solid-core wires and such sticking out of the back of the board with tweezers, and soldered.  You can do it!

If someone figures out a better board layout or way of getting the potentiometer connected, please share!

5. Solder on the speaker and piezo.

Just solder these on where the diagram shows.  They will be dangling off the board for the time being…

6. Connect the LCD module.

This section is called “Connect the LCD module”, but don’t actually do that yet.  First, check, then double-check, all of your work!  Once the LCD module is on there, it covers up your soldering, and there’s pretty much no getting it off.

DSC_0016If you are completely satisfied that all the connections look solid, and everything is connected as in the diagram, then cut a piece of duct tape to cover all the soldering and wire-wrap work on the underside of the board (aside from the wires that are sticking out for connecting to the LCD module).  This will prevent unwanted electrical contacts.

Now, use some pliers to make sure that all the stripped wires sticking out are as straightDSC_0017 as can be.  Once they are, start sliding the LCD module onto your board.  Try to get it as far down as it will go.

Once it’s all the way down, solder that sucker!

7. Glue on the speaker.

DSC_0021

Use the hot glue gun to glue the speaker to the duct-taped section of the board just below the LCD screen.

8. Almost there! Cut up the mint tin!

To start cutting away at the metal side of the mint tin, you can punch a hole through it with a hammer and nail.  Use the scrap piece of wood so you don’t destroy your mom’s nice countertop.  You can do this a few times if you want.  Be careful – the tin isn’t very sturdy.

Use the nibbler tool to make a nice, neat cutaway area for both the LCD display and the speaker.  I don’t have any good dimensions to give you; just estimate the best you can.

Once the mint tin is ready, you can squeeze the module in there and stick the piezo DSC_0026sensor to the clear plastic screen of the tin with a piece of tape.

9. Software…

You can write your own code for this project, or you can download it at the top of this post.

The code has programmed into it two songs: just two that I like, which I thought had simple, well-defined melodies and rhythms.  In the hopes of avoiding copyright prosecution, I’ve left the artists and titles out of this blog post, but you might be able to figure out what they are by listening.  And if that doesn’t work, you can always read the comments in the code.  If you feel like programming in your own songs, you can!  But it’s definitely time-consuming the way I have it set up…

The trickiest part of the coding for this project was reading the piezo sensor input while still controlling the display and music.  In addition to controlling both things at once, the code has to “debounce” the sensor input, and be careful about registering only one hit each time the user taps the back of the mint tin.  Then the code tries to decide if the registered hit is “good” or not, according to the closest beats in the song.

The other tricky part was dealing with the fact that the Arduino only has 2 KB of RAM.  I had to do a special trick to keep the music and strings in flash memory, and only read them out into RAM when necessary.

The code uses the LiquidCrystal library for controlling the Hitachi HD44780 compatible LCD module.  There are a couple of custom-drawn characters in the code, too.

10. Keep your fingers crossed and try it.

DSC_0015To load the software on, you have to connect the mint tin hero board up to your Arduino-less Arduino board (which in turn will be connected to your PC over the normal USB cable for loading software, but don’t connect to your PC yet).  Follow the diagram for the 2×3 header for the TX, RX, RESET, Vcc, and GND signals, and hook these up to the Arduino-less Arduino board.

With your mint tin hero board off (switch away from the outer edge of the board), connect the USB cable to your PC, and attempt to load the software.  Keep your fingers crossed…

If everything went well, you should see the LCD screen light up with “Mint Tin Hero!” displayed!  Congratulations!  (Well, you know, “congratulations” if it worked…)

You can disconnect the jumper wires and put in the two CR2016 batteries with the + side facing you.  The battery holder is meant to hold a single CR2032, so this is a hack – you want to make sure the that the little tab on the side of the battery holder is touching only the outermost battery’s + side, and not touching the inner battery at all.  You can flip the switch again and turn it on.

Final Thoughts

If you decide to try this project, I’d love to hear about it.  Good luck!

Advertisements

One thought on “Mint Tin Hero

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s