WebbotLib AVR library
WebbotLib It just does it
  C++ documentation  C documentation


The SOMO14D is an audio file playback device.
Manufactured by 4D Systems see http://www.4dsystems.com.au/prod.php?id=73 but available from other outlets such as SparkFun.
The micro sdCard (up to 2Gb) can hold up to 512 audio tracks in 'ad4' format. Check their website for a free utility to convert from other audio file formats. Each file name must be a 4 digit number, with leading zeroes', and an extension of '.ad4' ie '0000.ad4' to '0511.ad4'. This allows the files to be accessed by number rather than by name.
The device requires a 3.3v VCC supply as well as a common GND. Their data sheet shows how it can be powered from a 5v supply by the addition of some diodes to reduce the voltage.
The device is controlled by connecting two pins from your micro controller to the CLK and DATA pins. NB if your micro controller output pins are 5V then you need to add a 100 ohm resistor in series with each of these lines to allow for the fact that the SOMO is running at 3.3V.
An optional third wire can be connected from the BUSY output to your micro controller (no extra resistor need) so that your program can sense whether a sound file is still being played.
A loudspeaker can be connected directly to the SPK+ and SPK- outputs or the AUDIO output can be used with an external amplifier - see the data sheet.
You could use this device for playing background music, sound effects, speaking sentences, or you could store individual words as individual files and then play one after another to make up sentences on the fly.
Here is a very simple example that just plays a sound on powered up (assumes you have called the device 'mySomo' in Project Designer):
// Initialise the software
TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
// Play file '0000.ad4'
return 0;
// This is the main loop
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) {
// Nothing to do
return 0;
Here is another example that strings individual sounds together into a sequence so that they are played as single effect. Because we need to know when each individual sound has finished, so that we can start the next one in the sequence, then we need to make sure the 'Input pin from BUSY' parameter in Project Designer has been set up.
// Sequence of sound numbers ending in -1
int16_t effect1[] = { 1, 20, 15, 6, -1 };
int16_t effect2[] = { 1, 4, 5, -1 };
// Current sequence being played,
// initial value is NULL
int16_t* seqPos;
// Start playing a sequence of sounds
void play(int16_t* effect){
    // Stop any current playback
    seqPos = effect;
    // Start playing the first
    // sound in the sequence
// This is the main loop
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) {
    // If we are playing a sequence
        // And the current sound has finished
            // Move to next sound in sequence
            seqPos ++;
                // Sequence has finished
                seqPos = NULL;
                // Play next sound in sequence
    // All your other code goes here ie reading sensors,
    // controlling motors, servos etc.
    // Pseudo code
    if( robot has hit something){
        play(effect1); // Say "I banged my head"
    }else if( robot has fallen over){
        play(effect2); // Say "Ouch. What happened"
    return 0;
Function Summary

Valid XHTML 1.0 Transitional