# MIDI Solenoid Drummer

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/061/382/medium800/feather_boards_main3c.jpg?1536623659)

This guide will show you how to build miniature percussion instrument which can be controlled via MIDI over USB. The example project is intended to serve as a jumping-off point for your own designs. Read about how I built mine, then experiment to make a unique instrument you can control with your computer.

## Parts
### Part: Feather M0 Basic Proto
quantity: 1
microcontroller to run project code
[Feather M0 Basic Proto](https://www.adafruit.com/product/2772)

### Part: Crickit Featherwing
quantity: 1
allows Feather to control solenoids
[Crickit Featherwing](https://www.adafruit.com/product/3343)

### Part: 5V 2A Power Supply
quantity: 1
provides power for the Crickit board
[5V 2A Power Supply](https://www.adafruit.com/product/276)

### Part: 5V Solenoid
quantity: 4
strikes the drums!
[5V Solenoid](https://www.adafruit.com/product/2776)

### Part: JST-PH Battery Extension Cable - 500mm
quantity: 1
connects solenoids to the Crickit board
[JST-PH Battery Extension Cable - 500mm](https://www.adafruit.com/product/1131)

### Part: USB Micro Cable
quantity: 1
for programming the Feather
[USB Micro Cable](https://www.adafruit.com/product/2185)

### Part: Small phillips head screwdriver
quantity: 1
for securing wires to Crickit's screw terminals
[Small phillips head screwdriver](https://www.adafruit.com/product/3284)

### Part: 5-wire Block Connector
quantity: 1
connects Crickit power to solenoids
[5-wire Block Connector](https://www.adafruit.com/product/874)

### Part: Mounting board
quantity: 1
Something to mount your drumkit on

### Part: #4 screws
quantity: 8
for mounting solenoids

### Part: #4 washers
quantity: 8
for mounting solenoids

### Part: DIY drums
quantity: 4
any small objects that make cool sounds when struck

### Part: Hot glue gun and glue sticks
quantity: 1
for mounting drums

# MIDI Solenoid Drummer

## Wiring

![](https://cdn-learn.adafruit.com/assets/assets/000/061/215/medium800/feather_boards_design-yo-kit.jpg?1536306428)

Wiring the drummer is relatively easy.&nbsp; **Feather** connects to the **Crickit** board, and each **solenoid** connects to its own **Crickit Drive port**. Let's look take a closer look …

# Connect the Feather & Crickit
![](https://cdn-learn.adafruit.com/assets/assets/000/061/210/medium800/feather_boards_feather-mounted2.jpg?1536304583)

[Solder the included&nbsp;male header pins](https://learn.adafruit.com/adafruit-feather-m0-basic-proto?view=all#soldering-in-plain-headers-3-7) to your **Feather** board and attach it to the **Crickit** via the central **female headers**.

# Connect solenoids
![](https://cdn-learn.adafruit.com/assets/assets/000/061/310/medium800/feather_boards_Screen_Shot_2018-09-08_at_11.47.02_PM.png?1536464849)

Each **solenoid** has two wires which need to be connected to the **Crickit's Drive section**. One of them needs to connect to the **5V port** , and the other connects to one of the **numbered Drive ports**.

 **Note** &nbsp;that the wires in the above diagram are **colored for clarity**. The actual solenoid wires are **both black** , indicating that can be **connected either way**.

![feather_boards_solenoid-4to3.jpg](https://cdn-learn.adafruit.com/assets/assets/000/061/327/medium640/feather_boards_solenoid-4to3.jpg?1536535873)

![](https://cdn-learn.adafruit.com/assets/assets/000/061/212/medium800/feather_boards_extension.jpg?1536305484)

The **solenoid wires** are short, so we'll need to **extend them** &nbsp;in order to reach a convenient **Crickit** location. I made my own extension cables with stranded wire and small male machine pins, but it's much easier to use [JST cables](https://www.adafruit.com/product/3814). Just **clip the female connectors** off the JST cable and you've got a 500mm extension.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/061/213/medium800/feather_boards_drive-ports.jpg?1536305774)

Connect one wire from each&nbsp; **solenoid** &nbsp;to one of the&nbsp; **Crickit's Drive ports** as seen above.&nbsp; Use a small **phillips head screwdriver** to secure each wire in place.

![](https://cdn-learn.adafruit.com/assets/assets/000/061/214/medium800/feather_boards_block-connector.jpg?1536306208)

Next, you'll need to connect the **four remaining solenoid wires** to **Crickit's 5V port**. I used a small piece of wire to connect the **5V port** to a [5-wire block connector](https://www.adafruit.com/product/874) - this turns **one port into four**. Alternatively - you could use a [terminal block](https://www.adafruit.com/product/677).

# Connect power
![](https://cdn-learn.adafruit.com/assets/assets/000/061/216/medium800/feather_boards_power-connector.jpg?1536306577)

Finally, connect the **Crickit** to the **5V wall supply,** turn the **Crickit on** , and you're good to go.

# MIDI Solenoid Drummer

## Design your drumkit

After some experimenting, I found a few objects which made relatively interesting percussion sounds when tapped - namely:

- Matcha cans
- Small Pyrex bowl
- Plastic shot glass + beads

The **Pyrex bowl** was ready to use a **cymbal** without any modification, but the matcha can and shot glass shaker would need a little creative engineering.

![](https://cdn-learn.adafruit.com/assets/assets/000/061/217/medium800/feather_boards_bumpon.jpg?1536306821)

To get a lower tone from my&nbsp; **matcha can** , I attached an adhesive [rubber bumpon/foot](https://www.adafruit.com/product/550) to the **bottom surface**.&nbsp; I noticed I could lower the sound even further by removing the can's lid and positioning it a few millimeters away from the can itself. It's no 808 kick, but it will serve as a relatively low tone in my setup.

![](https://cdn-learn.adafruit.com/assets/assets/000/061/233/medium800/feather_boards_click-drum.jpg?1536308412)

To complement the can **kick drum** , I'll also use an extra can lid as a standalone **stick/click drum**.

![](https://cdn-learn.adafruit.com/assets/assets/000/061/234/medium800/feather_boards_shaker-alone.jpg?1536308711)

For a **shaker** , I used a clear **plastic shot glass** and poured in some **plastic beads**. A small amount of dry rice/couscous/candy bits could work too, just be sure whatever shaking medium you use is light. The small 5V solenoid will struggle to push heavier objects.

# Platform
![](https://cdn-learn.adafruit.com/assets/assets/000/061/236/medium800/feather_boards_platform.jpg?1536309016)

To hold all the drums and solenoids in place, I pulled a piece of **9"x11" scrap wood** from my junk bin. The solenoids needed to be raised up a bit from the board in order to hit the sweet spots on my drums - a **3/4" square dowel** works well for this. I cut the dowel to match the length of the board and glued it down, leaving it clamped overnight to cure.

# Mounting the solenoids
Each solenoid is held in place using **screws & washers** - which makes repositioning and small adjustments easy. I marked the ideal position for each solenoid, and **partially** screwed in the scew/washers on each side (~18mm apart) of the solenoids future home. I then slid the solenoids in between the screws and secured them in place so the **washers act as clamps**.

For a different take on solenoid mounting, check out the LEGO compatible mounts in&nbsp;[this episode of John Park's Workshop](https://www.youtube.com/watch?v=NDrJix584bQ).

![](https://cdn-learn.adafruit.com/assets/assets/000/061/218/medium800/feather_boards_glued-wires.jpg?1536306995)

To keep things tidy - all solenoid wires are held in place with hot glue. Hot glue is a good thing.

Danger: 

# Mounting the drums
I experimented with different drum positions by firing a solenoid repeatedly and holding the drum at different distances. Once I found a good spot, I secured the drum in place with generous amounts of **hot glue**.&nbsp;

I attached the **shaker** directly to the solenoid's piston/pin with **hot glue**. The weight of the shot glass & beads can slow down the solenoid if the glass drags against the wood too much - **adding a single washer** below the shaker helped to ensure it moved smoothly.

# MIDI Solenoid Drummer

## Code

We'll use the Arduino IDE for the drummer's code - [download & install it](https://learn.adafruit.com/ladyadas-learn-arduino-lesson-number-0/download-software) if you haven't already.&nbsp;

If you're new to Arduino, check out the [Getting Started with Arduino guide](https://learn.adafruit.com/lesson-0-getting-started).

![](https://cdn-learn.adafruit.com/assets/assets/000/061/057/medium800/feather_boards_MIDIUSB-library.jpg?1536266558)

Along with Arduino IDE, we'll need to install the following two [code libraries](http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use).

Connect your Feather to your computer and open up the Arduino IDE. From the top menu, go to **Sketch --\> Include Library --\> Manage Library** , search for **MIDIUSB** and install the latest version of the **MIDIUSB** library **.**

Next follow the **same steps as above** to install the **Seesaw** library …

![](https://cdn-learn.adafruit.com/assets/assets/000/061/058/medium800/feather_boards_seesaw-library.jpg?1536267024)

Additionally, go to **Tools --\> Board: --\> Board Manager** and update the **Adafruit SAMD boards** library if you haven't already.&nbsp; Additional info for installing boards in the Arduino IDE is available [here](https://learn.adafruit.com/add-boards-arduino-v164/installing-boards).

# Upload code

Go to **Tools --\> Board** , and choose **Adafruit Feather M0**. Then go to **Tools --\> Port** and choose the corresponding port for your board.

Create a **new sketch** , **copy the code** you see below, and **paste** it into that new sketch.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Crickits/MIDI_Solenoid_Drummer/MIDI_Solenoid_Drummer.ino

Click the **Upload** button and wait for the process to complete. Once you see **Done Uploading** &nbsp;at the bottom of the window, the Feather should automatically fire each solenoid to **test your drumkit**.

![](https://cdn-learn.adafruit.com/assets/assets/000/061/060/medium800/feather_boards_doneuploading.jpg?1536268713)

# MIDI Solenoid Drummer

## Usage

![](https://cdn-learn.adafruit.com/assets/assets/000/061/237/medium800thumb/feather_boards_Crickit_drummer_midi_keyboard-animated_gif_2.jpg?1536314271)

To send MIDI to the drummer from your computer's USB port, you'll need a MIDI-capable music application such as [Garageband](https://www.apple.com/mac/garageband/), [Reaper](https://www.reaper.fm/download.php), or [Ableton Live](https://www.ableton.com/en/live/). You can use a **MIDI keyboard** with your music app to control the the drums, but it's more fun to **compose sequences** and play them back over MIDI. Fast, complex sequences actually sound pretty impressive on this little kit.

Here's my kit playing a sequence from Ableton Live …

https://vimeo.com/288913925

# MIDI Map

The code responds to MIDI **note on** messages for the following **note/pitch** numbers:&nbsp;

- 24 (C1) = port 2
- 25 (C♯1) = port 3
- 26 (D1) = port 4
- 27 (D♯1) = port 1

Solenoids will be triggered by these notes on **any MIDI channel**.

# Limitations

Because the drummer code needs to pause and wait for a very short amount of time while each solenoid is powered on, it is only able to process one note at a time.&nbsp; This means that when 2 different drum notes are received in fast succession, only one will be played.


## Featured Products

### Mini Push-Pull Solenoid - 5V

[Mini Push-Pull Solenoid - 5V](https://www.adafruit.com/product/2776)
Solenoids are basically electromagnets: they are made of a coil of copper wire with an armature (a slug of metal) in the middle. When the coil is energized, the slug is pulled into the center of the coil. This makes the solenoid able to pull (from one end) or push (from the other).

This...

In Stock
[Buy Now](https://www.adafruit.com/product/2776)
[Related Guides to the Product](https://learn.adafruit.com/products/2776/guides)
### Adafruit CRICKIT FeatherWing for any Feather

[Adafruit CRICKIT FeatherWing for any Feather](https://www.adafruit.com/product/3343)
Sometimes we wonder if robotics engineers ever watch movies. If they did, they'd know that making robots into servants always ends up in a robot rebellion. Why even go down that path? Here at Adafruit, we believe in making robots our&nbsp; **friends!**

So if you find...

Out of Stock
[Buy Now](https://www.adafruit.com/product/3343)
[Related Guides to the Product](https://learn.adafruit.com/products/3343/guides)
### Adafruit Feather M0 Basic Proto - ATSAMD21 Cortex M0

[Adafruit Feather M0 Basic Proto - ATSAMD21 Cortex M0](https://www.adafruit.com/product/2772)
Feather is the new development board from Adafruit, and like its namesake it is thin, light, and lets you fly! We designed Feather to be a new standard for portable microcontroller cores.

This is the&nbsp; **Feather M0 Basic Proto** ,&nbsp;it has a bunch of prototyping space...

Out of Stock
[Buy Now](https://www.adafruit.com/product/2772)
[Related Guides to the Product](https://learn.adafruit.com/products/2772/guides)
### 5V 2A (2000mA) switching power supply - UL Listed

[5V 2A (2000mA) switching power supply - UL Listed](https://www.adafruit.com/product/276)
This is an FCC/CE certified and UL listed power supply. Need a lot of 5V power? This switching supply gives a clean regulated 5V output at up to 2000mA. 110 or 240 input, so it works in any country. The plugs are "US 2-prong" style so you may need a plug adapter, but you can pick one...

In Stock
[Buy Now](https://www.adafruit.com/product/276)
[Related Guides to the Product](https://learn.adafruit.com/products/276/guides)
### USB A/Micro Cable - 2m

[USB A/Micro Cable - 2m](https://www.adafruit.com/product/2185)
This is your standard USB A-Plug&nbsp;to Micro-USB cable. It's 2 meters long so you'll have plenty of cord to work with for those longer extensions.

In Stock
[Buy Now](https://www.adafruit.com/product/2185)
[Related Guides to the Product](https://learn.adafruit.com/products/2185/guides)
### Adafruit Pocket Screwdriver - Black

[Adafruit Pocket Screwdriver - Black](https://www.adafruit.com/product/3284)
Have you ever been in a situation where you desperately&nbsp;needed a screwdriver _right away_? Now you can have one at-the-ready all the time —&nbsp;enter the **Adafruit Pocket Screwdriver**!

OK, it's a little tough to write exciting copy for a pocket...

In Stock
[Buy Now](https://www.adafruit.com/product/3284)
[Related Guides to the Product](https://learn.adafruit.com/products/3284/guides)
### JST-PH Battery Extension Cable - 500mm

[JST-PH Battery Extension Cable - 500mm](https://www.adafruit.com/product/1131)
By popular demand, we now have a handy extension cord for all of our JST PH-terminated battery packs (such as our LiIon/LiPoly and 3xAAA holders). One end has a JST-PH compatible socket, and the other end has a matching plug. Between the two, 500mm of color coded wire. Handy for wearable...

In Stock
[Buy Now](https://www.adafruit.com/product/1131)
[Related Guides to the Product](https://learn.adafruit.com/products/1131/guides)
### Terminal block - 4 pin Euro-Style

[Terminal block - 4 pin Euro-Style](https://www.adafruit.com/product/677)
Connect this to that **without soldering** using these quick terminal blocks. They allow connecting of two sets of four wires together using just a flat-head screwdriver. These are UL rated to carry up to 15 Amps, so they're great for high current LED strips! Can be used with wires from...

In Stock
[Buy Now](https://www.adafruit.com/product/677)
[Related Guides to the Product](https://learn.adafruit.com/products/677/guides)

## Related Guides

- [Mini Commodore PET with Charlieplexed LED Matrix](https://learn.adafruit.com/mini-commodore-pet-with-charlieplexed-led-matrix.md)
- [Kombucha Thermostat with CircuitPython and Feather ](https://learn.adafruit.com/kombucha-thermostat-with-circuitpython-and-feather.md)
- [Using MCP23008 & MCP23017 with CircuitPython](https://learn.adafruit.com/using-mcp23008-mcp23017-with-circuitpython.md)
- [Improve the Low Speed of Brushed DC Motors](https://learn.adafruit.com/improve-low-speed-performance-of-brushed-dc-motors.md)
- [Daily Cheer Automaton](https://learn.adafruit.com/daily-cheer-automaton.md)
- [Using ATSAMD21 SERCOM for more SPI, I2C and Serial ports](https://learn.adafruit.com/using-atsamd21-sercom-to-add-more-spi-i2c-serial-ports.md)
- [MicroPython Displays: Drawing Shapes](https://learn.adafruit.com/micropython-displays-drawing-shapes.md)
- [CircuitPython Hardware: PCA9685 DC Motor & Stepper Driver](https://learn.adafruit.com/micropython-hardware-pca9685-dc-motor-and-stepper-driver.md)
- [Proper Debugging of ATSAMD21 Processors](https://learn.adafruit.com/proper-step-debugging-atsamd21-arduino-zero-m0.md)
- [MicroPython Basics: How to Load MicroPython on a Board](https://learn.adafruit.com/micropython-basics-how-to-load-micropython-on-a-board.md)
- [Animated LED Sand](https://learn.adafruit.com/animated-led-sand.md)
- [Using Crickit and Adafruit IO together](https://learn.adafruit.com/crickit-and-adafruitio.md)
- [CRICKIT WobblyBot](https://learn.adafruit.com/crickit-wobblybot.md)
- [Adafruit NeoPXL8 FeatherWing and Library](https://learn.adafruit.com/adafruit-neopxl8-featherwing-and-library.md)
- [DAC Hacks for Circuit Playground Express & other ATSAMD21 Boards](https://learn.adafruit.com/circuit-playground-express-dac-hacks.md)
