You could make an electronic greeting card with your own customized message or song, add a background soundtrack to a model train diorama, or create the world’s smartest whoopee cushion.
So will this play MP3s and stuff?
There are two phases to this project. The first (using a regular Arduino) loads sound data onto a flash memory chip, the second (using Trinket) plays it back. Both stages use some parts in common:
Winbond 25Q80BV serial flash memory (1 megabyte DIP). This can store about one minute of music or two minutes of voice, depending on quality.
Note this chip is discontinued! If you use a different chip you may have to modify your code, see here for an example.
- Breadboard(s) and jumper wires, or proto boards and related soldering paraphenalia
- Arduino Uno or similar board
- Capacitor: one 0.1 μF
- Resistors: 3 each 470 Ohm and 1K Ohm
- You can optionally add an LED (any color) and 220 Ohm resistor for a status indicator
Not all of these parts are available from Adafruit. You may be able to swap out for different parts you already have on-hand or can acquire locally; the “Loading Sounds” page has some guidance on alternative parts selection.
- Adafruit Trinket 3.3V (NOT 5V!)
- Capacitors: one 10 μF, 2 each 0.1 μF
- Resistor: one 68 Ohm
- 10K potentiometer
- Battery (or can use USB power)
The “Sound Playback” page likewise has some guidance on alternative parts selection. There’s a lot of wiggle room, not everything needs to be a super-precise value.
You'll need sound files in WAV format. You can search for downloadable examples on the internet (movie quotes, cartoon sounds, etc.), or record or convert something from your music collection using software such as Audacity (free download).
This project uses both Processing and the Arduino IDE. Both look very similar when running, which can lead to confusion, so make sure you’re loading the right code in the right editor! Processing is for writing code to run on your computer, while Arduino is for writing microcontroller code.
Download version 2.0 (or later) of Processing from processing.org (our software won’t work with the 1.5 version, if you currently have that installed).
If this is your first time using Trinket, work through the Introducing Trinket guide first; you need to install and then customize some settings in the Arduino IDE. Once you have it up and running (test the “blink” sketch), then download and install the TinyFlash library:
When properly installed, in the Arduino IDE you should then have access the rollover menu File→Sketchbook→Libraries→Adafruit_TinyFlash
The “examples” folder included with the library contains all the code for this project; there’s nothing else to download.
Why this weird flash memory chip? Why not an SD card?
- The flash chip is super affordable, so you can make it a permanent part of a small project. As it’s in DIP chip form, you don’t need to buy a special breakout board like you would for an SD card.
- Reading a FAT-formatted SD card with this tiny microcontroller is incredibly difficult; a single SD block would fill the chip’s entire RAM! We have seen projects that do this, so it’s not impossible but is nonetheless quite challenging. Perhaps we’ll revisit this idea in the future.