The Circuit Playground can also emulate a USB MIDI drum kit. This will let us play drums using the capacitive touch pads, or anything we hook up to them, like a bunch of fruit. But first, a bit of info on MIDI.
MIDI stands for Musical Instrument Digital Interface and encompasses a whole world of various hardware and software products. For our purposes, we can think in terms of a very simple setup as shown below.
The MIDI PRODUCER generates MIDI SIGNALS which are received by a MIDI CONSUMER that processes the command in the MIDI SIGNAL and takes some kind of action.
For a general overview of the structure of MIDI signals and the commands they contain, check out this episode of Collin's Lab.
For our setup, the Circuit Playground will be the MIDI PRODUCER and a computer will be the MIDI CONSUMER. The MIDI SIGNALS will be transmitted over USB. Software running on the computer will receive and process the MIDI commands.
Since we are going to turn the Circuit Playground into a drum kit, we can use a special set of MIDI commands defined in the General MIDI Specification. These commands use channel 10 to specify percussion (drums) and note numbers 35-81 to specify a specific instrument (kick, snare, hi-hat, etc.). For example, note number 56 is a cowbell.
Ok. Let's put the pieces together.
MIDI USB Library Install
In order to emulate a USB MIDI device, we will use the Arduino Library MIDIUSB. To install it, open up the Library Manager.
Sketch -> Include Library -> Manage Libraries...
Filter the libraries by typing 'midi usb' in the search box in the upper right. Then select the MIDIUSB library and click Install.
MIDI Drum Sketch
Here is the Arduino sketch to turn the Circuit Playground into a USB MIDI drum machine.
Download it and use the Arduino IDE to upload it to the Circuit Playground.
The following was only tested on Linux.
MIDI Drum Machine Software
We will use the software application Hydrogen to receive the MIDI signals from the Circuit Playground and play drum sounds. Downloads are available for Linux, Windows, and OS X.
The Hydrogen application is a full featured drum machine that let's you create drum patterns and full songs. For our simple Circuit Playground drum machine, we will ignore most of the user interface. The drum sounds are shown on the left side of the window and the corresponding Circuit Playground touch pad is shown in the figure below.
To enable the Circuit Playground in the Hydrogen software, first load the above sketch and make sure the Circuit Playground is connected via USB. Now, open the preferences window:
Tools -> Preferences
and select the Midi System tab. In the Input drop down, select the option with Circuit Playground in it. Also, check the Ignore note-off box. Then click OK.
At this point, if you touch one of the pads on the Circuit Playground you should hear a drum sound.
Making the Fruit Drums
Let's connect some fruit! Pretty much anything should work. Just get a bunch of fruit and hook them up using the alligator clips.
The alligator clip can be connected directly to fruit with a stem.
For fruit without a stem, a short jumper wire can be used.
One end of the alligator clip goes to the fruit, the other end to the touch pad on the Circuit Playground.
Once you've got your fruit all connected and arranged, it's time to rock out. The video below shows a brief demo of the Circuit Playground USB MIDI Fruit Drum Machine in action. Note that the Hydrogen app is running on the monitor in the background. The Circuit Playground is attached to the same PC via the USB cable.