Build a Lunar New Year Box: Talking, Portable, and Multi-lingual!

by gallaugher in Circuits > Microcontrollers

953 Views, 2 Favorites, 0 Comments

Build a Lunar New Year Box: Talking, Portable, and Multi-lingual!

Lunar New Year Box Demo

This wooden box has five buttons on the front & will offer a Lunar New Year greeting in Mandarin, Cantonese, Vietnamese, Korean, or American-accented English. Press a button, get a greeting, and place treats inside for extra fun.

Many of my students celebrate Lunar New Year, but are away from family, or may even be from outside of the United States. I've worked abroad myself and know how lonely it can be during holiday time when you're away from home. Noting this, each year at Lunar New Year I bake cookies for my students, cut in the shape of that year's Lunar Zodiac animal. Several years ago I made a cardboard box version of this build with a CircuitPlayground Express, alligator clips, and capacitive touch pads (here's a video), Code from the lesson "You've Got the Beat" in CircuitPython School can be easily adapted for a CircuitPlayground capacitive touch box like my first iteration. But this year I wanted to make a more sturdy build that I could use year after year. I also wanted it to be portable.

Here are instructions on how I built my box. Hopefully you find this useful in creating a similar build of your own. And, of course, you can replace the sounds for other phrases and music, rather than Lunar New Year, modifying the build to work for whatever occasion you'd like. If you enjoy this tutorial, do let me know! Build on!

Supplies

parts.png


  • Wooden box - This one came painted in red, has a front clasp, and is fairly sturdy. The 1/4" wood held up well to the holes I drilled.
  • Adafruit Feather RP2040 - this project works with just about any microcontroller that runs CircuitPython. I like the Feather RP2040 because it has pass-through charging so a LiPo battery can be added to make the project portable when unplugged.
  • Hamburger Speaker - the project will be portable since speakers like this have a built-in battery that charges over a separate USB cable.
  • 5 momentary push buttons (not latching button/switches) - 1/4" button shaft width is a good choice. These are the ones I used, but I would have chosen buttons with a stem length (note width) longer than 1/4" so I could use the nut to mount the buttons to wood, but I hot-glued the buttons in and that seems to hold them well, too.
  • Thin acrylic for face plate - optional, only if you want a black face plate, as shown. Not necessary since the buttons have a lip to cover the drilled hole. However, I drilled my first hole off-center, so this was a nice way to cover up my flub.
  • Hookup wire - for wiring up buttons and speaker to photo board and microcontroller.
  • Solder
  • Adafruit Perma-Proto board - It was useful to solder grounds from all five buttons and the speaker to a ground rail on this board, then solder from that same ground rail to the ground on the microcontroller. Adafruit gives these away free for large orders.
  • Heat shrink - for securing soldered wires.
  • Gorilla tough tape (or similar) - I used this to tape down wires inside the box.
  • Thumb tacks - for tacking down the microcontroller inside the box.
  • Double-sided tape (useful for mounting face plate before drilling, and taping drill guides to the box)
  • Velcro tape
  • Fabric to fit inside the box and cover electronics (I used a tea-towel purchased from a local hardware store).
  • Optional, but if you want your project to be portable - LiPo battery, 1200 mAh is a good size. Make sure it has a JST connector so it can attach to the Feather's battery connector. If you're using LiPo batteries, be sure you know the risks associated with these products and safety precautions to take. You're on your own to find out what you need to in order to be safe. I assume no liability at all for this build, design, etc.

Equipment & additional supplies

  • Soldering iron
  • Drill with 1/4" drill bit
  • Hot glue gun and glue sticks
  • Red magic marker to color in drill holes (I used dry-erase simply because it was on hand).
  • Heat shrink gun (unless you want to shrink tubing using a lighter)
  • Ruler
  • Sticker paper to print flag stickers (or buy separate flag stickers)

Code, Sounds, and Wiring Diagram

lunar new year box wiring diagram.png

Code & "sounds" file containing five sounds used in this build can all be found in the GitHub repot at:

https://github.com/gallaugher/lunar-new-year-box

Wiring diagram is shown above. The Feather RP2040 wiring scheme I used had the signal terminal for the 5 buttons wired to:

  • D5, D6, D9, D10, and D11

Ground wires all went to a ground rail on the Perma-Proto board, then that rain was wired to the GND pin of the Feather RP2040.

The base of the hamburger speaker's RCA jack was wired to the ground rail, as well.

The tip of the hamburger speaker's RCA jack was wired to the A1 pin on the Feather RP2040.


Drill, Sand, and Color Holes for Buttons, Speaker, and USB Cables

drill-button-holes.png
speaker-holes.png
dry-erase.png

If you would like to add a face plate, like the black plate shown, the one I used was 9" x 3".

  • Cut out a piece of black plastic with these dimensions (you can use a razor-blade knife & straight edge. Work slowly).
  • Add double-sided tape to the backside of the face plate and affix it the desired spot on the front of the box.

Drill Button Holes

  • Printout the drilling template named "5-button-hole-drilling-template.pdf", cut out the template, and affix it to the front of the box in the spot where you want to drill your button holes.
  • Drill five 1/4" holes through the box, and through the faceplate if using the faceplate.

Drill Speaker Holes

The enclosed template works for the type of hamburger speaker linked above, which is 2" across, and has a 1.5" grill.

  • Printout the drilling template named "speaker-holes-drilling-template", cut out the template, and affix it to the side of the box in the spot where you want to create audio holes so that you can more easily hear your speaker. I placed mine on the left side, toward the front of the box.
  • Using a 1/8" drill bit, drill 9 holes, starting with the center hole, then four outer holes. A box that's 1/4" thick should be able to then allow you to drill the additional four holes so you have 9 holes in total. This will allow sound to escape and make it easier to hear the various phrases when played from the speaker.

Create an opening in the back to snake in two USB cables - one for the Feather RP2040 microcontroller, and the other for the hamburger speaker.

  • Measure the size of the hole needed based on the width of the cable that would pass through the hole. Be sure to leave some extra space to account for the width of the wire when passing through the second cable while one cable is already through the hole. I found drilling two 1/4" holes side-by-side created a large enough gap to pass cables through.

Sand and color holes as needed

  • If the holes seem rough, you can sand the holes on the inside of the box, only (not on the outside - you don't want to ruin the finish of the box).
  • If the holes show up with natural wood and you feel this clashes with the paint on the box, color the wood inside the holes. While you could paint, I found that using a red white-board marker colored the holes quickly and with enough red to hide the wood color from the holes.

Wire the Buttons

button-soldering.png

Refer to the wiring diagram in the section above when performing the steps below.

Momentary push buttons have two terminals, one for ground and one for signal. Buttons of this type don't have polarity, so it doesn't matter which pin goes to which wire. Do choose a consistent wire color for ground wires, since you'll be soldering all five ground wires to a ground rain on the Perma Proto board.

  • Measure and cut 5 ground wires (it's best to keep color the same, since they'll all be going to the Perma Proto board). There should be more than enough space for the wires to go from the button terminal to the permanent photo board, with wires lying flat on the bottom of the box. Strip both ends of these wires.
  • Also measure and strip 5 signal wires. These wires will go from each button to a pinout on the Feather RP2040 board.
  • Tin the terminals and one end of each wire, then solder one ground wire to one terminal of each button. BE CAREFUL and DO NOT hold the soldering tip on the terminal for too long. If you do, you might melt the plastic around the terminal and the terminal might fall off. Work quickly and if solder isn't flowing fast enough, be sure to wait a bit before trying again so that the terminal and the plastic housing can cool down and the plastic button stem won't melt. I actually destroyed two buttons while attempting to wire them up. Fortunately the package of buttons I ordered (see the parts list) came with more buttons than I needed.
  • Solder one signal wire to the remaining terminal on each button. Again, be careful so as not to melt the plastic button stem.
  • Slide a piece of heat shrink over the wire and on top of the terminal so that no metal is visible. Heat the heat shrink (I use a heat gun, if you use a flame, do be careful) until the tubing shrinks and forms a seal around the wire and terminal.
  • Thread each of the five buttons through the button hole so the push button is at the front of the box and the wires are inside the box.

Solder the ground wires

  • Thread each terminal wire from each of the five buttons to a pinhole in the ground rail in the Perma Proto board. These boards are just like breadboards, but they are flat and meant for permanent soldering. The rails on the ends of the boards are all connected, just like the ground and power rails of a breadboard. Blue is the preferred rail for ground wires (red is for power, but we're not wiring anything to the photo other than ground).
  • Strip and solder another wire with one end soldered to a free pinhole on the ground rain of the Perma Proto board, and the other soldered to the GND pin of the Feather RP2040 microcontroller.

Solder the signal wires

  • Pass the remaining stripped end of each button signal wire to the appropriate pinout on the Feather RP2040 board. The code is written so that the five buttons will be wired to pinouts D5, D6, D9, D10, and D11, respectively.

Wire and Mount the Speaker

speaker wiring.png

Wire the speaker

  • Measure a length of wire to be used for the ground wire that will go from the speaker's RCA jack to the Perma Proto ground rail. Strip both ends of the wire.
  • Measure a length of wire to be used as the audio out wire from the Feather RP2040 microcontroller to the tip of the speaker's RCA jack. Strip both ends of the wire.
  • Tin the sleeve or base/bottom of the speaker's metal RCA jack (see diagram above). The sleeve at the bottom is the ground area of the plug.
  • Tin one end of the ground wire, then solder it to the sleeve of the RCA jack.
  • Tin the tip of the RCA jack (see diagram above). The tip of the jack carries the audio signal into the speaker.
  • Tin one end of the signal wire, then solder it to the tip of the RCA jack.
  • Cut two bits of heat shrink and thread them over the wires and around the jack so that the two wires and solder joints will be held in place. Then heat the shrink (again, I used a hot air gun) until the heat shrink shrinks and forms a solid seal for the wire and solder joints.


Copy Code & Sound Files & Test

Before securing all of the parts, make sure everything is working by downloading the files, running code, and testing the hardware. Buttons should produce the expected sound.

I'm assuming you have installed CircuitPython on your board. Also, make sure that the "lib" folder of the board's CIRCUITPY volume contains the library: adafruit_debouncer. If you are completely new to CircuitPython, steps on setting up your board should be included in the Adafruit Learn Guide for your board. There are also tutorial documents in CircuitPython School on my YouTube Channel.

  • Open a browser and visit the GitHub repo at: http://github.com/gallaugher/lunar-new-year-box
  • Download code.py, as well as the entire folder named "sounds", which should contain the files "mandarin.wav", "cantonese.wav", "vietnamese.wav", "korean.wav", and "english.wav".
  • Plug your microcontroller using a USB data cable (be sure it's not a charge-only cable, or this will not work). Plug the other end into your computer. If you have properly set up CircuitPython, as mentioned above, then you should see a CIRCUITPY volume mounted on your computer, just as a USB drive would mount.
  • Make sure that your speaker is plugged in to its USB cable, with the other end plugged into a USB power source. Also make sure the speaker is turned on.
  • Drag code.py into the CIRCUITPY volume so the file copies over.
  • Drag the "sound" folder into the CIRCUITPY volume so those files copy over, as well. The code.py file should run as soon as the last files have been copied.

You should now be able to press the buttons and hear the appropriate sound file play. If something is wrong, then there is a problem with your hardware, or with your wiring or soldering. Double check and make sure everything is working properly before continuing.

Connect the Speaker's USB Cable and Mount the Speaker in the Box

Inside of box with wiring.png

Glue in the speaker

  • Thread the speaker's USB charging cable through the back of the box and plug it into the hamburger speaker.
  • Position the speaker inside the box so that the grill of the speaker is right up against the holes you drilled to allow sound to escape from the box. The USB cable should be plugged in and threaded through the hole at the back of the box.
  • Turn the speaker on.
  • Use copious amounts of hot glue to glue the speaker to the side and bottom of the box.
  • You can also glue the speaker's USB cable to the side of the box to keep it out of the way.

While you can turn the speaker off, if you'd like, you'll have to reach in to the mounted speaker (I found needle nose pliers allowed me to more easily grab the switch without pulling the speaker away from the box).

Secure Components and Wiring

Glue in the buttons

  • Working from the inside of the box, hot glue the back, wired-end of the button stem into the appropriate hole. No one will see this side, so it's OK to use copious amounts of glue. Hold the button in while gluing so that the glue hardens with the button in position. Work with the front of the box positioned downward so that gravity drips glue into the hole and around the button stem.

Secure remaining components

  • If you're using a LiPo battery, plug it into the JST connector on the microcontroller (they only fit in one way, so take a look at the JST connector and port and make sure you're pushing it in the right way - be careful as the wires are delicate and can be broken off).
  • Thread the microcontroller's USB cable into the box and plug it into the microcontroller.
  • Bunch wires neatly, flat against the bottom of the box. Make sure wires can drop from the button stems to the bottom of the box without staring the wires, solder joints, button stems, speakers, photo board, or microcontroller.
  • Once wires are positioned properly secure wiring and Perma Proto board to the bottom of the box using heavy tape (I used Gorilla Tough Tape).
  • Secure the microcontroller to the bottom of the box. I did this by thumbtacking the two mounting holes in the corners of the microcontroller that were closest to the microcontroller's USB port.

Add a Fabric Linear to the Box

velcro tape and fabric.png
  • Make sure your fabric linear will cover the wires and create a nice, clean area for you to place items into the box. I used a small kitchen-style tea towel.
  • Separate the two pieces of velcro tape and find the side that sticks best to the fabric liner.
  • Measure four pieces of the velcro tape to fit on the inside of the box and secure the top of the fabric liner near the top end of the bottom of the box.
  • Remove the backing on each of the four pieces of velcro tape and stick it to the appropriate place inside the box. Press it in so the seal is tight.
  • Position the fabric linear so that it attaches to the velcro and provides a nicely-sized covering to the taped wires and electronics that were on the floor of the box.
  • Create stickers appropriate for the language "spoken" by each button press. The file "flags.pdf" contains images that I printed onto sticker tape, the cut and fixed to the front of my box, just above each button. The pdf also includes flags I didn't use, but that you might find useful for your own box.

You're now ready to load your box up with goodies and share with students, friends, family, and anyone else you'd like to wish a Happy Lunar Near Year to.

Downloads

Enjoy This Tutorial? There's Lots More!

make-something-awesome.png

This tutorial was created by Prof. John Gallaugher. All lessons for his university Physical Computing course using CircuitPython (and the CircuitPlayground Bluefruit, Arduino Nano RP2040 Connect, and Raspberry Pi) are up on his YouTube channel, as are videos used in his zero-to-full-stack Swift/iOS programming course. You can find all this material and many more step-by-step build tutorials at:

https://YouTube.com/profgallaugher

Prof. Gallaugher is also active on Twitter. Did you find this material useful? Be sure to let him know @gallaugher. Cheers!