Adding Sound to Projects

For a recent project, I needed to add some sounds to a product. There are many ways to do this, but I needed to play quite complex sounds and have an easy way of changing the sounds (via an .mp3 or .wav file).

This led me to the “WTV020-SD” IC which is a full mp3 voice module. There are loads of these available. I bought a couple from Embedded Adventures, as they are in the UK (so had short shipping time to me) and came with a micro SD card which is known to work with this IC.

These are my notes on getting this board up and running with sound output and connecting it to an Arduino micro-controller.

The WTV020-SD data sheet is here. This IC is available in break-out boards vey cheaply via eBay. I decided to order mine from Embedded Adventures, as they had local stock (timescale was an issue for this project) and they came with the correct micro SD card. I had heard that not all micro SD cards are alike and some do not work with the IC, so I wanted to remove any variables or hassle. Follow this link to the product page, called the MOD-1007. The board with 1Gb micro SD card cost £15.95 + VAT.

I ordered three of the boards. Here is one when it arrived:

To remove the micro SD card you need to slide the card slightly to the far side of the board. It then springs up and you can remove by then pulling in the other direction.


I also added some header pins to the module so that I could use it with some breadboard.


The data sheet for the module (MOD-1007) is here. The first thing to note when reading about this IC and module is that it plays back files which are in the .ad4 format (rather than .mp3 or .wav, which I am more used to). The .ad4 format is a 4-bit ADPCM audio file which can use sample rates from 6kHz to 32kHz. Luckily there are a number of converters to change .mp3 and .wav files into .ad4 files, including this one linked to via the Embedded Adventures website. I downloaded that zip file.

Extract the program and run the .exe file. This will install the conversion program. I found no problems with the installer. This installs a program called “UsbRecorder” under the heading “Usb Recording Notebook”.

I did not have a micro SD card reader, so I picked a cheap one up from the £1 shop:


I plugged this into my computer and it did the self-install thing and said it was ready to use. I followed the MOD-1007 data sheet guide for converting files. The conversion program is designed to be used with another product, we are just using it to convert files. I clicked on “Local File” tab and then browsed for a folder of music. I had to click on the .mp3 extension to view them (it automatically tries to find .wav files). I changed the sample rate to “original”. I then highlighted all the files I wished to convert and clicked on the “AD4 encode” button. This encodes all the files selected and puts a .ad4 version of the file into the same directory. I did a whole album, hence it took quite a while but a blue progress bar shows the program is doing something. Once this is complete you can see the files by clicking the .ad4 extension button.

There is a bit of hassle with the files. To get them to play properly you must rename them starting with 0000.ad4, then 0001.ad4 etc. This I did manually, but I am sure could be automated. For this project I only require 4 or 5 sound effects (hence 1Gb is a bit of memory overkill….) but for this test I used a whole album – 17 songs, renamed 0000.ad4 to 0016.ad4.

I copied these to the micro SD card using the USB SD card reader. I then safely removed the SD card (so that the Mass Storage Device was shut down properly). I now has an SD card full of tunes.


I had some 40mm 8 ohm speakers lying around (from the Bat Listener Kit). The module can directly drive 8 ohm speakers, so I wired up this to the SPK connections on the MOD-007.


The board runs on 3.3V Vcc, so I rigged it up to a 3.3V supply on Vcc and GND. This works as a stand alone module and you can pull various pins to ground to change tunes and play tracks. It does not need any pull up resistors. I did not add any additional wires and powered it up. Using a flying ground wire, I pulled PLY to GND and it burst into life. Its pretty loud (certainly good enough for my application) and consumes around 70-100mA when playing a tune.



Next thing is to control it via my microcontroller (an Arduino Uno-based board).

As well as working as a stand alone unit, this device can also be controlled via a serial-type connection. A minimum of three pins are required (RESET, CLOCK, Serial Data IN) with the addition of a fourth (BUSY) to check when playback has ended.

The main thing to note is that this unit runs on 3.3V, while the Arduino runs at 5V. My project already has a 3.3V regulator on-board (the MCP1703 3.3V 250mA LVDO regulator). This means any data lines must also be level shifted. To start with I am using a potential divider comprised of a 2k2 resistor and a 3k3 resistor. The 5V from the Arduino is applied to the potential divider and the output is 5V x (3.3/(2.2+3.3)) = 3V, which is enough to signal a logic 1 within the device.

The has been an Arduino library written which is available here, but I wanted to keep things very simple, so I decided to write my own. I did not need full functionality – I just needed to play three or four sounds depending upon different situations decided within my Arduino code.

Following the MOD-1007 data sheet, to start any communication you should first reset the device. Do this by pulling the RST line low for a minimum of 5mS and then waiting at least 300mS. This should be done each time we start to communicate, but not inbetween each command.

To send a command we need to set the CLK line low for >2mS and then clock in the serial data (16 bits for each comand, most significant bit (MSB) first). Change the data line while the CLK is low and then set the CLK high. Each CLK pulse should be at lease 50uS long.

The BSY line will be high during playback. To monitor when playback is finished then monitor the BSY line.

There are not many commands (maybe the IC has more, but they are not in the MOD-1007 datasheet). The commands are:

  • 0x0000 to 0x01FF – Start playback 0000.ad4 to start playback 0511.ad4
  • 0xFFFx –  Set volume: 0xfff0 mute to 0xfff7 loud (default)
  • 0xFFFE –  Play (or pause if already playing)
  • 0xFFFF –  Stop playback

I only really need to use the commands to start a playback, as the volume control and other functions will not be used.

The code shown here is a very simple ‘get you started’ code to play tracks from your sound module. This code runs through all the tacks on the SD card, starting at 0000.ad4 and incrementing by 1 each time. It plays 10 seconds of the track (set with a delay function), then moves on to the next one. I have not implemented a test of the BSY line, but it is not really needed for my application. The code wakes up the unit (by sending the reset command). It then sends the number of the track to play as a 16 bit binary number (0 to 15). This must be read from MSB to LSB. To do this I use a for loop that counts from 0 to 15, but read the bits from 15 down to 0. I use the bitRead function to clock out the various bits.

This code (a sketch) is available to download here.

//  Name    : MOD-1007 sound unit Arduino Control Example                              
//  Author  : Matt Little 
//  Date    : 25/11/2012      
//  Modified: 25/11/12                                 
//  Version : 1.0                                         
//  Notes   : Code for playing files from the  MOD1007 unit        
//          : This uses an Arduino to control the MOD-1007 sound unit
//          : from Embedded Adventures
//          : This has code to play a file and adjust the volume
//          : To play a file we send the file number 0x0000 to 0x01FF
//          : Which plays files 0000.ad4 to 0511.ad4
//          : See for more detail
//          : The lines used are (but these can be changed):
//          : RST = A1, CLK = A2, SDATA = A3, BSY = A4
int RST = A1;
int CLK = A2;
int SDATA = A3;
//int BSY = A4;
unsigned long tune = 0x0000;  // This is the tune file to play
void setup() {
  Serial.begin(9600);    // Set up a serial output for data display and changing parameters
  pinMode(RST, OUTPUT);     // set pin to output
  pinMode(CLK, OUTPUT);     // set pin to output
  pinMode(SDATA, OUTPUT);     // set pin to output
  //pinMode(BSY, INPUT);     // set pin to output
  // initialise the outputs
  digitalWrite(RST, HIGH);
  digitalWrite(CLK, HIGH);
  digitalWrite(SDATA, LOW);
void loop() {
  // put your main code here, to run repeatedly: 
  // The unit needs to be reset before sending commands
  // Reset means pull the line low for 5m then wait for >300mS
  digitalWrite(CLK, HIGH);
  delay(5);  // Wait a bit
  digitalWrite(RST, LOW);
  delay(5);  // Wait >5mS
  digitalWrite(RST, HIGH);
  delay(300);  // Wait >300mS  
  digitalWrite(CLK, LOW);  
  delay(3);  // Wait >2mS    
  // Here we start to clock in the data
  // Want to play track 1 (send the number 0x0000)
  // This is a 16 bit binary number
  // It would be best to have a function that you can send a 16 bit number to and it will paly the song
  // So lets have a long which holds the number
  for(int t=0;t<=15;t++)
    // We read each bit in the long data file
    // If it is high then set the SData line high
    // We want to read out the MSB first
        digitalWrite(SDATA, HIGH);
        digitalWrite(SDATA, LOW);
    // Then we need to clock through the data
    digitalWrite(CLK, HIGH);  
    delayMicroseconds(50);   // Clock pulses should be >50uS 
    digitalWrite(CLK, LOW);
    delayMicroseconds(50);   // Clock pulses should be >50uS 
  delay(10000);  // wait 10 seconds before trying anything else
  tune = tune++;
  Serial.print("The next track is: ");

Rather than using the if()…else() section we can make the code a bit smaller by using these lines, where the bitRead data is used directly as the output. This is not as obvious but does exactly the same thing:

    digitalWrite(SDATA, bitRead(tune,(15-t)));  

I’ve now got sounds being controlled from my Arduino set up using this simple and relatively cheap module.

One response to “Adding Sound to Projects

  1. I use the WTV020-SD-16p and find them great little modules. I get them off eBay for about £3 and used uSD cards also from eBay. I had real problems getting compatible SD cards until I discovered SDFormatter ( Now all my 1GB cards of differing brands work fine. Also I use WAV as I dont like the compressed quality of AD4. I use these module for simple short sat nav like clips as well as reasonable 5 minute+ audio playback (mono). I typically use the attiny84 or 85 as the controlling MCU running on batteries, either 2xAA (3v ish) or 4xAA rechargables (4.8v) just making sure you solder the correct jumper on the audio mudule (3.3v or 5v)

Leave a Reply

Your email address will not be published. Required fields are marked *