Skip to content
Nick Johnson edited this page Jun 30, 2015 · 1 revision

Getting Started

This tutorial walks you through some first steps using your Tsunami. Before doing this tutorial, you should have completed Installation.

Your first sketch

Open the Arduino IDE, and click the up arrow icon to open a sketch. Select the 'libraries' entry, then the 'tsunami' entry, then the 'SineOutput' entry.

SineOutput is a simple demonstration of the Tsunami's signal output capabilities. It generates a series of frequencies corresponding to musical notes, from 110Hz (A2) to 7902Hz (B8). We'll go through the code briefly:

/** 
 * SineOutput.ino
 * Generates a 400Hz sine wave using the Tsunami.
 */

#include <SPI.h>
#include <tsunami.h>

First, we import the Tsunami and SPI libraries. All Tsunami sketches require that the SPI library be imported as well, as SPI is used to communicate between the microcontroller and the other components on the board.

void setup() {
  // Initialize the Tsunami
  Tsunami.begin();
}

In the setup routine, we initialize everything, which in this case is a simple matter of calling Tsunami.begin(), which does all the work for us.

void loop() {
    float frequency;
    while(1) {
            frequency = 110.0;
            while(frequency < 8000.0) {
                Tsunami.setFrequency(frequency);
                frequency *= 1.05946309; // 12th root of 2
                delay(500);
            }
        }
    }
}

In the loop function, we declare a start frequency of 110Hz, then repeatedly:

  1. Tell the Tsunami to output the current frequency
  2. Multiply the frequency by the 12th root of 2 - the 'magic' number that will generate the next frequency in the pentatonic scale.
  3. Wait 500 milliseconds

We repeat this until we hit 8KHz, at which point the outer loop runs again, resetting the frequency back to 110Hz and starting again.

Uploading the sketch

Now that you've loaded and examined the sketch, it's time to upload it to the Tsunami and test it out.

First, you need to make sure you have the correct board and port selected. Click 'Tools' in the Arduino menu, then choose 'Board' and click on 'Arachnid Labs Tsunami'. Then, click 'Tools' again, select 'Port' and pick the port corresponding to the Tsunami. On Mac and Linux that will probably be something of the kind "/dev/tty.something". On Windows, it will be "COMx" - if you have multiple entries, select the highest numbered one.

Once you've done that, click the 'Upload' button in the IDE to program the SineWave sketch to the Tsunami.

Testing it out

If you have an oscilloscope, hook it up to the Tsunami's signal output. If you have a speaker, or an amplifier such as the Tymkrs Amplify Me kit, plug that in to the Tsunami and have a listen. You should see - or hear - a series of rising scales.

Next steps

If you'd like to learn more about how to program the Tsunami, check out the Tutorials section or the Reference. If you'd like to try out more of the Tsunami's features, check out the documentation for the FrequencyGenerator sketch.