Have had lots of fun and games trying to get the Arduino element of the player to work, so far.
Firstly, getting the newly-purchased SD card to read was relatively straightforward. Once I worked out that I could transfer the files through my camera (as I don’t have an SD card reader other than the one I had just bought to attach to the Arduino), testing to see if it was connected and reading the files on there worked okay. Once I had reformatted the card for FAT32, at least. There is still an issue with some of the files having names too long for the DOS 8.3 naming convention, but I will rename these later.
Next, I bought the additional components (amplifier chip and capacitors) for, and built, this circuit:
Unfortunately, not realising there was a difference between the Arduino DUE board, which this circuit was designed for, and the Arduino (Elegoo) UNO I have, took me off on the wrong track somewhat and cost me a fair bit of time. Essentially, the DUE uses the Audio.h library, which needs the DAC port. A port my UNO sadly doesn’t have.
So, next, lots of Googling, trying to find a simpler circuit and code that uses the TMRpcm library instead. For a while, every bit of code I verified was giving me errors similar to this one (I tried a few!):
So then I decided to try the other computer, and the same lines of code all worked fine.
Next, to build the circuit. I tried to build this:
But the wiring around the capacitors and amp chip lost me completely.
Then I started working with this code – https://maxoffsky.com/maxoffsky-blog/how-to-play-wav-audio-files-with-arduino-uno-and-microsd-card/ – and finally managed to play various of the .wav files on the card
(although the audio was so distorted it was sometimes hard to tell!).
But how to make the circuit, so that it wasn’t just plugged straight into the Arduino board? After a couple of false starts, I found and built this:
This meant I now had very distorted, but louder audio from the speaker.
- Build the more complex amplifier circuit above that works on the UNO, ideally with a potentiometer for volume control
- Find and write the code to play the .wavs whenever a tilt switch is activated, and turn off again when tilted back into place
- Find and write the code to make this happen randomly (ie play one of the eight .wav files at random) when the player is tilted forward (rather than the current keyboard entry in serial monitor)
- Last, but definitely not least, think about how the circuitry and power can fit inside the player shell
Watch this space.