Introduction: Arduino MIDI Controller - Techshop Using Scarff Boarduino
I've looked around at a number of different arduino solutions for MIDI. My project concept involves over 100 analog inputs that each sense velocity and provide MIDI output. Using the background info i got from techshop class i decided to set this up first with six analog inputs.
This Arduino that is sold by Tom Scarff is called 'boarduino' He ships quickly and is very reliable and responsive to silly questions by beginners. It's an ATmega168 microcontroller chip; analog 0 thru 5 pins; and comes preprogrammed with a "no-wait" Arduino bootloader 2 red LEDs, power and "pin 13" just like the Arduino Diecimila with a 16 hz clock (resonator) It has the 2-pin header for MIDI OUT.
The arduino source code is available on his site.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Building a Midi Controller With the Boarduino
Tom Scarff is an expert in this field. He supported me on my previous midi project, "a midi controlled, pneumatically operated, fire breathing dinosaur named Lunarsaurus which I showed at Maker Faire.
So I turned to him for this project and found that he already had a kit (called a boarduino) ready to go.
http://midikits.net23.net/midi_boarduino/midi_boarduino.htm The Boarduino is interesting because of its size. It's tiny (.75" x 3.75") and will fit in a small spot and the price is good. I prefer to buy it assembled - one less variable.
The easiest way to get started is to put a 9v battery on the standard 2.1 mm. Here a word of warning. You need to keep the power source within spec. I left my battery plugged in over a week or so, it dropped down below 9v and the microprocessor (trying as hard as it might) lost its marbles. Fortunately one can re-upload the code and you are back in business.
You can also provide 5vDC to the serial pin or the board but be very careful as there is no diode to protect you for reverse polarity (as there is with the 9v external plug).
Step 2: Setting Up the Scarff Boarduino
This is all pretty straight forward. Here I started with basic switches turning each of the channels up and down (i had this group of five switches laying around - there are actually six inputs). One side of the switches (keys) tied to ground, and the other side running directly to the analog input on the boarduino.
The only thing that I left out that was the pull down resistors. Yes it's on the website and yup - I messed up. So I had a terrible cacophonous howling which was mildly interesting until i put some 1M ohm resistors from ground to the analog input. The howling was all of the channels going on or off depending on ambient RF and such.
Plug the midi cable from the boarduino to your synth (or midi in on your keyboard) and it works right out of the box.
Step 3: Adding Piezos
Now that I have the off/on micro switches working the mid inputs I switched them out for 12mm piezo that i found on ebay. Same wiring diagram. I experimented with several ways to mount and actuate the piezos. Simply mounting them on a flat surface and touching with your fingers does a reasonably good job. I experimented with a number of different configurations for mounting the piezos. I found that having a simple test jig allowed me to more reliably measure the response. Hot gluing them to 1/2" foam is good too. Cut holes in the foam, drop the wires through and you are done.
The piezo generates electricity based on the amount of deflection in the crystal. Some piezos used in instrumentation are gripped on the side (a cantilever mount). I chose to make small indentations in the backing material that would allow the piezos to bend and flex. So mounting the piezos is an important consideration when your goal is to read the current from individual keystrokes. It's not like using a piezo as a pickup on a guitar.
One must be careful when attaching devices to the analog pins. The piezos can generate voltages from -20vdc to +60vdc. I put them on a scope and it's quite an interesting wave form. The clamping diodes on the ATmel allow up to 1 milliamp (1000 microamps). So the 1M ohm pull down resistor helps protect the analog inputs on the arduino.
In the end the piezos worked fine - but getting the analog inputs on the board to recognize and turn them reliably into a midi signal is a work in progress. This is why I like working with Tom. He's already come up with some different designs for my unique needs. So the next task is figuring out how to add some subtle circuitry that will make the arduino a little more responsive.
I've tried implementing this simple circuit (below) to the output and I think that with some changes in the code and tuning of the circuit I will have a good basic design.
Now onto the next step - adding a mux. Which again - Tom Scarff cranked out in short order. There is still quite a bit of design work left but i'm very pleased with the initial product; a six note midi controller (soon to be expanded).
Step 4: Hooking the BUB Up to the Boarduino to Download Code
Here is a fritzed drawing of the board which shows 7 1M resistors instead of 6 (?). Each of the piezos will have the copper disk grounded(black wire on mine), and the ceramic side (red) directly on the analog input. The boardino is sold with a midi (din) connector with a pair of 220 ohm resistors, etc.
To get the arduino software going follow instructions for mac drivers.
When editing the source files using arduino software on my mac i used these settings.
tools -> serial port : tty.usbserial*
tools-> board : Arduino Diecimila or Duemilanovie w/ ATmega 168
tools-> programmer: avirisp mkIII
Oh! When it comes to using the BUB (mind from modern devices) to upload the software on the boarduino you may need to flip it upside down. If you read the labels on the pins it will make sense. If there is no light on the board and you have your BUB hooked up, the reversed pin-out cold be the reason.
Hook it up and download!
Step 5: Finally, I Hooked This Up to Piezos
crude but simple. i machined a dimple that left a cavity behind the piezo to allow the crystal to flex. (see the empty hole).
i cut this out in a few minutes after dinner so i had something to test the piezos with. i mounted it to a standard break-out box and put a midi jack on the side. a 9v battery fits inside. So - a complete, battery powered midi controller that is 2" x 6". The scarff board really works well in situations where you want to fit it into a small area !
Step 6: Low Pass Filters for Piezos Used As a Keyboard
I'm still playing around with different filters. tuning piezos circuits is a challenge. here is a pdf showing another approach. I'm still using the BAT 85 shottky - but i can't tell the difference between this and other diodes.
No need for a Zener to limit the analog input. Arduino can handle up to 100 volts, as long as the amperage is below a 1 milliamp. So brief signal spikes of 5-10 volts on the analog inputs should not be an issue.
This arrangement (with a diode right off the piezo, and a 1M pull down) seems to be the best starting point.