This is a pretty simple project, also the little wood house might look familiar, because it's the same house I've used for the IoTThe Thesmart house project (an off-the-shelf product I've bought online - it's not even laser-cut. I had this idea of making it into a Christmas decoration with some DIY materials bought from a local dollar shop (including the mini wooden fences), and to put a functional music playing device inside the small cabin without many exposed electronic parts.
I've used a dedicate MP3 player module in my lightsaber fixing project. It is convenient, but the module generates white noises whenever powering up. So I decided to try an alternative of using CircuitPython, for some boards can play WAV or MP3 files directly from its simulated-USB storage (for which you can directly drag and drop files).
On the other hand, most CircuitPython-supported boards do not have a lot of internal storage space; most Adafruit Express boards has additional 2MB flash, some may have 4MB or 8MB. So I add a SPI SD card module, and this also allows me to add or delete music without having to reprogramm the board. The content of the memory card will be mounted can accessed directly.
The ProjectI've tried to write the code as generic as I can: in theory this works on any Adafruit M4/SAMD51, RP2040 and ESP32-S2 boards (M0/SAMD21 firmwares do not support MP3) with minimal changes. The whole thing uses one single button switch, one SD card module, amplifier/speaker and optional NeoPixel LEDs.
(See the video I've posted on Twitter.)
In my own example I used a LM386 amplifier with a 8 ohms/0.5 watts speaker, which is way enough to play classic Christmas songs. You can use other combinations or attach a 3.5mm jack, etc. (If you are using a stereo amplifier, use only right or left side channel. It does not matter for CircuitPython.)
How to UseSince the code sorts all .mp3 files by name, you should name the files as 01.xxx, 02.xxx... at root. If the device is powered on without a SD card, or the card has no MP3 files, or your firmware lacks some required Python module, the on-board LED (either NeoPixel or Dotstar, if there is one) will flashed red.
All internal/external LEDs, if there is any, will cycle through the same rainbow color. You can decorate them wherever you like. Be noted that you should consider the power consumption issue if you have lots of LEDs.
The single button serves three functions: a short press (less than 0.4 secs) pause/resume the music. Medium press (0.4~1.2 secs) will skip to next track. Long press (longer than 1.2 secs) will jump back to the first track.
Since this is meant to be a decoration (which plays background Christmas music on its own) than a actual music player, I don't need external displays or more controls. But it won't be too difficult if you want to expand this into a full-feature MP3 player.
* * *
NOTE - the audio amplifier wiring below is missing a connection between input "g" and GND of the board.
Comments