In this 3 part article we teach you how to control electronic solenoids from Ableton Live, by using some Arduino programming, a little bit of MIDI knowledge, and some basic electronics.
At the end of the series you will have a setup that is capable doing this.
This is a pretty complex topic so it is split into 3 parts to make it easier to follow. The 3 parts cover:
- Hardware - Arduino Leonardo, Solenoids, and Output Transistors
- Software - Arduino source code and MIDI programming
- Ableton Live - Mapping from inside Ableton through an Arduino
Feel free to jump around to all of the parts to get a feel for what is going on.
Part 1 - Arduino and Hardware
In this article we cover the hardware requirements for playing solenoids from Ableton Live. In order to play MIDI notes on solenoids you need the following hardware:
- An Arduino with native USB, such as a Leonardo
- A few micro solenoids
- An equal number of output transistor modules
- Enough power to fire the solenoids
Each part of this list is very flexible and you can use whatever parts you have on hand.
Arduino with Native USB
You need to use an Arduino that has native USB support. This project uses the MIDIUSB Library which relies on an Arduino device with native USB functionality. This means that you need a device such as a Leonardo, Micro, Due, or Zero. We used an Arduino Leonardo clone from Borderless Electronics, but you can also use a genuine Arduino like this one. The Arduino is the connection between Ableton Live and the output transistors.
The MIDI data is generated by Ableton Live and is sent out the USB port to an Arduino using the External Instrument MIDI device built in to Ableton Live. The Arduino software interprets the MIDI stream and uses it to turn output pins on and off.
The output pins are connected to transistor modules that connect the solenoid to the battery, causing the center plunger in the solenoid to move.
The software that we used for this demo is open source and shared in the next article.
Solenoids
You can theoretically use anything for the output sound here. Motors, relays, and buzzers will all work as long as your transistors can drive them and you provide enough power. We chose to use solenoids. You can get the solenoids on Ebay for very cheap. A typical solenoid looks like this:
The ones we used have a 4mm stroke, require 12 Volts and 120 milliamps, and have a spring return.
The spring return is important. Be sure that you buy a solenoid with spring return. This is what brings the plunger back to neutral when you turn the pin off and remove power to the solenoid.
You can most likely use 5 volt solenoids as well, just be sure to use a matching power supply.
Solenoids have 2 wires, frequently a black wire and a red wire, but in reality the color of the wires is not important. When you apply power to the wires an electromagnet is created and the center plunger moves forward. Then when you remove power the electromagnetic field collapses and the center plunger is free to return to neutral.
It does not matter which way you hook the solenoid wires up, but if they have black and red wires then it is common to connect the black wire to ground (GND) and the red wire to plus (+).
Mount and Wire the Solenoids
It's nice to have the solenoids mounted to something with a bit of mass so that you can set them next to what they are going to hit and make noise. Many times the come with metric tapped holes that you can use to mount them. We chose to use E6000 glue and simply glued the solenoids down to some scrap aluminum flat bar. Be sure to align the solenoid so that the plunger pushes past the edge of the flat bar when it is in the forward position.
Extend the wires of the solenoids to 3 or 4 feet with any flexible wire. We used 24 AWG zip cord from Amazon.
Solder the solenoid wires to the zip cord and insulate it with some heat shrink tubing if you have it. Attach the wires to the mass as a strain relief because these little solenoids are going to be moved around a lot.
Output Transistors
In order for the Arduino to turn something on and off like a solenoid (or a motor, buzzer, or other device) there needs to be an output driver between the Arduino and the device that is being turned on. The simplest output driver is a transistor. An easy way to get a transistor is to buy one that is already mounted on a board with screw terminals, all ready to go. For this project we used these.
They have an IRF520 MOSFET on them which is perfect for controlling from an Arduino pin. They are capable of driving up to 5 amps each, which is about 40 times as much as we need (our solenoids only require 120 milliamps, or 0.120 amps). With the screw terminals they are simple to wire up in a project like this.
The wiring is simple, partly because these transistor modules have a common ground, meaning your power ground and your Arduino ground are connected to each other.
Connect your Arduino output pin to the transistor modules SIG pin, which stands for signal input. When the Arduino pin is high the transistor will turn on, the solenoid will fire, and the plunger in the solenoid will move forward. The VCC pin on these modules is not connected to anything and can be ignored. It is only there to make the connector compatible with other output devices.
When the Arduino pin is low the transistor will turn off disconnecting the power supply from the solenoid and the spring return in the solenoid will return the plunger back to its normal resting place.
Note that we don't need an h-bridge in this circuit because the spring on the solenoid returns the plunger back when we remove power. An h-bridge would be needed if we wanted to do something like spin a motor both forward and backward. In this case the spring is our reverse.
Power Supply
The last thing that you need for this project is some sort of power supply to move the solenoids. The output from the Arduino is not strong enough so we are running it through a transistor. The transistor will turn some sort of power on and off, but we need to provide that power.
It can be simple, such as a 9 volt battery or a few AA cells in series to get at least 6 volts. You can use an RC battery or a recycled wall wart. If you use the IRF520 transistors that we used above then a 12 volt supply will work perfectly.
The power supply is connected to the VIN and GND pins of the transistor modules. If you have more than 1 module then you have to connect them all together, in parallel.
On these modules the two grounds, both labeled GND, are connected together on the back plane. This means that there is no reason to run a second ground wire from the Arduino to the 3 pin header; the high current ground connection on the 2 pin screw terminal is sufficient, as long as at least one ground wire runs from your power supply back to your Arduino.
In addition these modules do not use the VCC pin so you can ignore it on all of them. Each module needs to connect to a dedicated output pin on the Arduino. We used pins 0 through 5, but you can use whatever pins you like. You will have to modify the pin assignments near the top of the source code file in the next article. It looks like this:
// these are the arduino pins that the solenoids are hooked up to
enum drumPins {kickPin = 0, snarePin = 1, hhPin = 2, crashPin = 3, cowbellPin = 4 , openhatPin = 5};
If you use a different arduino you might have different pin mappings.
Powering the Arduino
A note about providing power to the Arduino. The Arduino can get power from either the USB port when it is connected to your PC or from the on-board power regulator.
Since this project is connected to your PC when in use we do not have to provide any sort of other power for the Arduino. However, since we have 12 volts available you can connect the pin labeled VIN on a Leonardo to your 12 volt rail without any problems. The Arduino Leonardo is fully capable of dual source power, and 12 volts is not too much for the on board regulator. This feature is taken advantage of on some other projects on this site.
In this project simply power the Arduino over USB while powering the output solenoids with a separate 12 volt source (unless you buy 5 volt solenoids, then use a 5 volt source for them). Be sure to connect your Arduino's ground and your power supply's ground together so that the output transistors actually turn on.
Debugging without a Power Supply
You can debug your code without the power supply turned on without issue. The output modules that we used here will still light up to let you know that they are getting an on signal from the Arduino, but it will not be as bright as when the external power supply is connected. Since there is no power connected, the solenoids will not move. Then once you have your code working properly you can connect the external power supply and the solenoids should start moving. Remember that the external power supply is independent of the USB power that the Arduino is running on.
That should be all the hardware that you need to make an Ableton Live powered Arduino solenoid project. We mounted it all together on a piece of plywood so that it would survive a few months of experimentation.
Source Code
The next article covers the Arduino source code and MIDI theory needed to make this project work. MIDI Controlled Solenoids with Arduino and Ableton Live - Software and MIDI If you have any questions please feel free to ask them in the comment section below.