Today we are going introduce another useful kit from adafruit industries – their waveshild Arduino shield kit. The purpose of this shield is to play audio files sourced from a computer, at the request of an Arduino sketch. It is an interesting product in that it meets one of the needs of the original concept of Arduino, that is:
… It’s intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments. (arduino.cc)
Yes – yes indeed. For a while I had seen this kit, and though that there wasn’t much point to it. But if you spend a few moments contemplating how the control of sounds or recorded voice could be used, suddenly you have a “light bulb moment” and come up with all sorts of things, both crazy and sensible. Once again, this kit arrives in typical adafruit packaging, a simple reusable antistatic bag:
and emptying the contents onto the desk reveals the following:
And before anyone asks me, no the parts don’t arrange themselves as they fall out of the bag. If they did, we’d have some much larger problems in the world. At first glance I was worried that not all of the parts had been included, however this is kit version 1.1, and there will be empty spaces on the PCB. Speaking of which, once again it is a nice thick, solder-masked and nicely silk screened PCB.
The pre-assembly checklist, assembly instructions and all other documentation and required software links can be found on the adafruit website. After checking off the included parts against the adafruit bill of materials, it was time to start. You will need a few extra things, for example a speaker if necessary, an SD memory card (up to one gigabyte in size) – and in my case two 8-pin IC sockets. When you live in an area where finding specialised ICs is difficult or just time-consuming, IC sockets are very cheap insurance.
The first item to solder in is the SD card, and this is a surface-mount part. But don’t let that worry you, it ‘clicks’ into the PCB, and you then just hold it down with one hand while holding some solder, and with the other hand heat each pad for two seconds and let some solder flow over the pads:
And you don’t need to solder in the last three, narrower contacts of the reader – they are not used. Everything else is standard through hole, nothing much to worry about apart from burning yourself while listening to the radio. Except for one resistor, R6 – the one next to IC4. If you solder in the resistor first, even though it sits normally – it is about one millimetre too close to the IC. So if you are going to assemble this, solder in IC4 before R6:
However it isn’t anything to panic about, just something to keep an eye out for. Moving forward, everything else went in easily:
The last basic soldering to take care of is the expansion pins for the shield to able to mate with other shields. The easiest way to solder these in is to first drop the new pins into an existing, matching board – as such:
Then drop the waveshield on top of the pins and solder away:
And finally, some links from the circuit to the digital pins… Then lo and behold, we’re finished:
During the initial testing and experimenting, I was going to use a set of earphones to listen to the output, however instead ended up installing a small 0.25 watt 8 ohm speaker. The solder pads for the speaker are between the rear of the headphone socket and C9. If you decide to use both headphones and a speaker, the circuit is designed in such a way as the headphone socket will cut off the speaker when headphones are in use. adafruit also sell the waveshield party pack which includes a memory card and speaker to save you shopping around.
Note that this shield will need digital pins 2~5 and 10~13 – as noted in Jon Oxer’s new website – shieldlist.org.
Now that the hardware has been taken care of, let’s get our Arduino talking and grooving. The first thing to do is install the wavehc library into your Arduino IDE software. The library and related buffering use a fair amount of memory, so if you are running an Arduino with the old ‘168 MCU, it’s time to find the $6 and upgrade to the ATmega328.
Next, visit the tronixstuff file repository. Download the waveshieldtest.pde sketch; and also download this audio file onto the SD card. Finally, insert the SD card, upload the sketch, insert your headphones and the board should play the file. Don’t forget to turn the volume up a little, yours may be set to off by default.
Now that we know it is working, it is time to examine how we can control things in more detail. The most important thing is to have your .wav sound files in the correct format. The maximum sampling rate is 22 kHz, depth of 16-bit, and in mono PCM format. You can download an open-source audio editor package to do the conversions for you here. ladyada has also written a good conversion tutorial for you here.
Apart from converting audio files for playback, if you want to get some backchat you will need to find a speech-synthesiser. You can make use of the AT+T Labs Natural Voices (R) Text to Speech demo website for this. Just enter some text, and then you can download the .wav file:
Now let’s have a quick look at how we can play files on demand, to let our own projects make some noise. Please download the sketch waveshieldtest2.pde. Although there is a large amount of code in there, what we’re interested in is just the void loop(); function. To play a .wav file, such as “wisdom.wav”, just use
So you can just mash that sketch and your own code together to get some files playing, however don’t forget your attributions to the original authors. Here is a … longer demonstration of waveshieldtest2.pde:
As always, thank you for reading and I look forward to your comments and so on. Furthermore, don’t be shy in pointing out errors or places that could use improvement. Please subscribe using one of the methods at the top-right of this web page to receive updates on new posts. Or join our Google Group.
[Note - The kit was purchased by myself personally and reviewed without notifying the manufacturer or retailer]
Latest posts by John Boxall (see all)
- Arduino Workshop – A Hands-On Introduction with 65 Projects - May 6, 2014
- Project Review – Silicon Chip Capacitance Substitution Box - April 23, 2014
- Add long-distance connectivity to your Arduino with the CATkit System - April 13, 2014