Here is a short checklist of the box I wanted to build:
- Box with dimensions of 300x300x300mm.
- Decorated to resemble the Mario mystery box from the classic super Mario bros game.
- Equipped with light up walls that would colorfully blink when the box is hit/moved.
- Equipped with a speaker that would play theme song and a coin sound when the box is hit/moved.
- Equipped with accelerate to detect box movements.
And this is what the Mario mystery box ended up looking:
Initially I was going to use a raspberry pi for controlling LED strips, reading accelerometer and playing sounds. Unfortunately, I ran into few things I was not quite happy about while trying to use raspberry pi for this project:
- Price was quite too high for a simple thing that I wanted.
- Power consumption was too high for a standby condition.
- It was nearly impossible to control individually addressable LED strips due to hard time requirements.
- Audio output was awful...
At some point I made a lucky mistake due to which I needed to replace my raspberry pi. At that point I started to wonder if I could use something else... an old android smartphone! It turned out to be a good choice for me because:
- You can get an old smartphone really cheap.
- It has on-board sensors, including accelerometer.
- Bunch of APIs for easy interfacing with the sensors.
- On board touch screen for control interface.
- On board battery and charging circuit.
- Good quality audio output.
So I got myself an old phone and made a service running in a background and monitoring accelerometer. Whenever the phone would move it would play the coin sound. Otherwise it would play the Mario theme song.
So far, so good. The shortcoming of using a phone for this is, of course, the fact that it does not have any IOs. I decided to solve this by hooking up a custom board running ATmega64 microncontroller. This board served the following functions:
- Controlling individually addressable LED strips.
- Reading input switches for enabling/disabling functions of the box.
The smartphone and the custom board communicate through a serial RS232 cable using a custom communication protocol I set up. I programmed the ATmega64 with several LED sequences that the smartphone could trigger and a way to pull the states of several IOs of the microcontroller. This way I could setup switches to disable the song playback or all functions together.
Here is the insides of the box I ended up and the components on it:
In the end, there was a number of things I would like to improve, but all in all, the box did what I wanted it to do.
When I carried around the box it was playing Mario theme song, and making couple of light effects on it's walls. Here is a short video demonstrating it:
When shaken the box would interrupt the theme song, play a coin sound and blink the walls. Here's a short video demonstrating that effect:
And here's a short clip from the comic con event: