Make Music With Motion!

Make Music With Motion!

Takumi Ogata · 02/25/26

Whenever you're looking at a photo on your phone, you can turn it sideways and the photo will change its orientation. But how did your phone know that you turned it? Well, there's a sensor in your phone called an accelerometer!

This sensor can measure the orientation in X, Y, and Z directions, so it's suited for adding tilt control to a device. What's cool is that you can easily buy this sensor on Adafruit for your next DIY project. Today, let's experiment with making music with the accelerometer!

Credit: ADXL335 photo by Adafruit

Items Needed

Electronics

Let's start by taking a closer look at how this ADXL335 accelerometer from Adafruit works! This sensor outputs varying voltage values according to its orientation. For example, as it's tilted more in the x-direction, the Xout pin's output will increase. And if it's tilted more in the y-direction, the Yout pin's output will increase.

Voltage values like this can be read by the Daisy Seed. With this microcontroller, you can program a synthesizer, use a sensor to control the sound, and output the audio from its onboard pins. For example, a knob can be twisted clockwise and the pitch of a tone increases. This works by connecting a potentiometer's varying voltage output to the Seed's ADC pin.

Once the value is read, it can be mapped to the synth's parameter, in this case, the pitch!

This particular accelerometer's output pins work in a similar way, so it'll be easy to control the pitch by tilting!

With that in mind, let's start hooking up some components to the Daisy!

In order to connect the Daisy's audio output to an audio interface, an audio jack needs to be connected to the audio out pin. To get the accelerometer working with the Daisy, first bridge the analog and digital grounds together. Then, connect the ground to the sensor's ground pin. After that, connect the Daisy's analog 3.3 volt pin to the sensor's Vin pin. Finally, connect the ADC 0 pin to the Xout. While at it, let's connect the ADC 1 pin to the Yout.

Now that a motion synth is built here, let's start programming!

Programming 

As for programming, different languages can be used to program a DIY synth for the Daisy platform! For this tutorial, let's use Plugdata as it is quick to set up and easy to program with any Daisy board. You can install it from their download page.

A good first test when working with a new sensor is to display the output value on a serial monitor. Here's a Plugdata patch that prints the sensor's value. This patch, along with other files in this blog, can be downloaded from this link.

Serial_Print_X_Axis.pd

By compiling this patch with the custom JSON file, accelerometer.json, in the same download folder, the [r x_axis ...] object outputs the voltage value read by the Daisy's ADC 0 pin.

Here's what accelereometer.json looks like:

{
    "name": "motion_synth",
    "som": "seed",
    "audio": {
        "channels": 2
    },
    "components": {
        "x_axis": {
            "component": "AnalogControl",
            "pin": 15
        },
        "y_axis": {
            "component": "AnalogControl",
            "pin": 16
        }
    }
}

So, this JSON file maps the [receive] object and the ADC 0 pin together. Notice where the name "x_axis" is set and note that pin D15 is the Daisy's ADC 0 pin.

Let's compile and flash this program to the Daisy. Click the "Main menu" icon at the top and select "Compile". After installing the toolchain, select "Custom JSON..." as the target board and open the custom JSON file mentioned earlier. Then, toggle "Debug printing" to "Yes".

Before flashing a program, the Daisy needs to be put into a flash-able state. Hold down the BOOT button while inserting the USB cable into the Daisy. Now, click the "Flash" button in Plugdata.

Using the Arduino IDE's Serial Monitor (you can watch this video to learn how to set it up for the Daisy), you should see a sensor value between 0.0 and 1.0 printed after selecting Daisy as the board and usbmodem as the port.

Tilt the synth from one end to the other in the x-axis direction and see if the value changes! The maximum value should be around 0.55, minimum around 0.35, and flat at around 0.45. The y-axis works similarly.

Let's Start Controlling Sound

Now the fun begins! Let's use the x-axis and y-axis sensor values and program a motion synth! The first obvious synth parameter to start with is pitch! The goal is to tilt the synth more to increase the pitch and vice versa! Here's the patch that maps the x-axis to the pitch of an oscillator.

Motion_Pitch_Raw.pd

The aforementioned range is scaled to be between 0.0 and 1.0, which is easier to do math with, by subtracting 0.35 from the input value and then multiplying by 5. This value is then scaled between 440 and 880 for the oscillator's frequency range. Flash the patch and see if you hear a change in pitch as you tilt around!

You may have noticed the pitch warbling when the movement is a bit shaky. The good news is that you can smooth out the sensor data with the [line~] object!

Motion_Pitch_Smoothed.pd

By increasing the ramp time of this object, the sensor value becomes smoother! Be careful not to smooth it out too much (e.g., 1000 milliseconds), otherwise, you start hearing an obvious latency.

Ok, let's get some gnarly sounds happening! What if the sensor value is mapped to an FM synth growl?

Motion_Growl_X_Axis.pd

Let's map the x-axis value to the FM synth's depth parameter. It's also mapped to a low-pass filter in order to make the growl sweep sound more pronounced!

And let's not forget that you have one more control, the y-axis!

Motion_Growl_&_Freq_Shift.pd

Let's map it to the Heavy frequency shifter abstraction by Wasted Audio that comes with Plugdata. Now, you have two parameters that you can control simultaneously with one hand!

Half-Sphere

While this motion synth is really fun to play with, it can be a little tiring to hold it in the air while performing. One solution is to put it on top of a half-sphere styrofoam, place it on a table, and tilt it around. You should be able to find one on Amazon. The diameter of the half-sphere in the photo below is about 3.9 inches or 10 centimeters. It should feel more stable and fun to play with!

Effects

What if this motion synth is used as an effects unit? Let's add some movement to a hardware synth.

All you need to do is add another audio jack for the input.

And here's the effects patch.

 

Motion_Effects_LP_&_Verb.pd

This patch maps the x-axis to a low-pass filter. The y-axis is mapped to the dry/wet control of the abstraction ([Space]), which includes a heavy reverb and a chorus (fx.chorus~.pd) made by MikeMorenoDSP!


Space.pd

Conclusion

Hope you had fun with your new motion synth! Here are some things that you may have observed about using an accelerometer for making music.

Being able to control two parameters at once with one hand can feel expressive!

Of course, you can control two parameters at once with one of those joy-stick mod wheels. This leads to the next point: dynamic movement! Compared to a knob or mod wheel, playing this motion synth can feel more dynamic. If this sphere were bigger, it's easy to imagine that it would feel even more dynamic and fun to perform with! And an instrument that looks dynamic to perform with should be fun for the audience to watch as well.

And if you have built a handheld DIY synth (or a keytar!), it could be fun to embed an accelerometer to add more control!

Hopefully, this tutorial gave you new ideas for your next DIY synth project! And if you're looking for other cool sensors to make music with, check out this video on ribbon synth!

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.