Introduction: Arduino MIDI Foot Pedal Keyboard
The Origin
My dad is a musician. He can play a multitude of instruments. However, he only has two arms, BUT he also has legs! That's when we decided that we would reuse the foot pedals from an old organ and convert them into an arduino powered MIDI keyboard. Now he can easily play electric guitar and fill the empty sound with excellent bass notes produced from his QS8 Quadrasynth.
An Introduction to MIDI
MIDI stands for Musical Instrument Digital Interface. As you can guess, it conducts all operations digitally. MIDI doesn't send sound frequencies as instruments do. MIDI works generally with two parts: a controller and a synthesizer. The controller is what is manipulated by the musician and sends serial data to the synthesizer.
The MIDI controller does not make any sound on its own. It REQUIRES some form of a synthesizer. The synthesizer decodes the serial data and produces sound based on the given data.
MIDI data is commonly sent in three parts: the MIDI channel (up to 16 channels can be used at once), the note, and the velocity (basically the volume of the note or how loud you want it to be).
Step 1: Materials
-Organ (to salvage foot pedals from)
-Two ATmega328 ICs with arduino boot loader
-Seats to place the ICs in once soldered.
-Two 16 MHz crystals
-Four 22pF ceramic capacitors
-Perf board
-Power supply and adapter for ATmega ICs
-220 Ohm resistor
-Pull down resistors for the Pedals
-MIDI cable or Female MIDI connector
-Arduino and USB cable (for programming the IC. A separate programmer can be used in its place)
-Computer for programming
-Solder and Soldering Iron
-Wire Strippers and cutters
-Potentiometer (Potentially the volume pedal salvaged from organ [see what I did there?])
-At least twenty six pin connector (salvaged from organ)
-Wire
I ordered my arduino parts, crystals, powersupply, and capacitors from http://cutedigi.com. Use a common 12V power adapter to power the powersupply. I can't imagine this project drawing much current, so I'm sure a 500mA power adapter will suffice.
Step 2: Obtaining the Foot Pedals
The organ used in this instructable is a Wurlitzer organ. My dad found it on craigslist and picked it up for $25!! Everything worked, but he didn't care for the tone. The pedals, however, were perfect. There are twenty five keys and the switches are built into the pedals instead of mounted inside the organ with the pedals hitting the switches. Also note how the switches use magnets to connect the switch. These switches will be almost impossible to wear out! Consider taking the volume pedal as well. It controls a potentiometer, which is pertinent to our interests!
This organ has an interesting version of a Leslie speaker. That might be used for another project on another day.
Step 3: Making a Dual Stand-Alone Arduino
The 16 MHZ crystal is connected to pins 9 and 10 of the IC. One capacitor is also connected to pin 9 and then to ground, while the other to pin 10 and then to ground.
Solder the IC seats, powersupply, crystals, capacitors, and connector down to the perf board. Print out the picture of the ATmega Arduino pinout. Write whatever you used to label the pedal wires down on each. My dad simply labeled them like the notes: C, C+, D, D+, E, etc. (+ meaning #) This will help with the programming step. Send a +5V wire to one side of all the pedal switches. The returning wires from the pedals are wired to the digital inputs of the IC. Be sure to include pull down resistors on the inputs for the pedals.
When the MIDI cable is being wired to the board, only three pins are used of the five: +5V, GND, and a serial transmit on digital pin 1 (pin 3 on the IC). A 220 Ohm resistor needs to be wired between the +5V and MIDI output to prevent damage to the synthesizer or MIDI sequencer.
Analog pin 5 on both ATmegas are wired to the middle pin of a potentiometer. In my case, the potentiometer was in the volume pedal of the organ. The other two pins of the potentiometer are wired to +5V and GND.
The following list depicts the schematic. Please excuse the redundancy of re-listing the parts.
----------------------------------------------------------------------------------------------------------------------------------------
C1 Ceramic Disk Capacitor package THT; rated voltage 200V; capacitance 22pF; capacitor type Ceramic C2 Ceramic Disk Capacitor package THT; rated voltage 200V; capacitance 22pF; capacitor type Ceramic C3 Ceramic Disk Capacitor package THT; rated voltage 200V; capacitance 22pF; capacitor type Ceramic C4 Ceramic Disk Capacitor package THT; rated voltage 200V; capacitance 22pF; capacitor type Ceramic DIN1 DIN-5 jack (MIDI) package THT; form jack (female); pins 5 J1 Generic double row male header - 28 pins package THT; hole size 1.0mm,0.508mm; row double; form ♂ (male); pins 28; pin spacing 0.1in (2.54mm) R1 220 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 220Ω; pin spacing 400 mil R3 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil R4 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil R5 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil R6 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil R7 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil R8 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil R9 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil R10 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil R11 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil R12 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil R13 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil R14 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil R15 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil R16 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil R17 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil R18 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil R19 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil R20 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil R21 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil R22 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil R23 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil R24 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil R25 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil R26 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil R27 390 Ω Resistor package THT; tolerance ±5%; bands 4; resistance 390Ω; pin spacing 400 mil U1 atmega328 package DIP28 (Dual Inline) [THT]; version Atmega328-20PU; type ATMEGA328 U2 atmega328 package DIP28 (Dual Inline) [THT]; version Atmega328-20PU; type ATMEGA328 XTAL1 Crystal package THT; frequency 16 Mhz; type crystal; pin spacing 5.08mm XTAL2 Crystal package THT; frequency 16 Mhz; type crystal; pin spacing 5.08mm
Step 4: Writing the Code
When a pedal is pressed, the command is sent to turn on the note at a certain velocity. The potentiometer (volume pedal) is used to determine that. It gives values from 0-1023. The map function is used to proportionally map that number to another number between 0-127. To turn a note off when the pedal is not pressed, the same command for that note is sent, except the velocity is 0.
Having the arduinos send that command when a pedal is pushed using an "if" statement in the loop would work except it would send that command every time the loop repeats when the pedal is down. If the "else" statement is also used to send the command to stop the note (velocity 0), then the arduinos would send that command for every pedal that's not pressed every time the loop repeats. The arduinos and synthesizer couldn't handle sending or receiving all that data.
To fix this, the arduinos must send the command to play a note ONCE after the pedal is pressed. They must also do the same for when the pedal is released. In order to do this, the arduinos must "remember" the last state (pressed or not-pressed) the pedals were in the last time the loop repeated.
To add that feature, I made a "last state" variable. The first thing the arduinos do after sensing when a pedal has been pressed is compare the last state they were in to the state they are now. This makes it possible for the arduinos to send the command for a note ONCE when it has been pressed and ONCE when it has been released.
Because there are two Arduinos, there are two programs that are written. It's simply copying the first one and pasting it into a new project and changing all the notes. Remember that one program will use one more note than another!
BOTH Arduinos need to send commands on the SAME MIDI channel. I used MIDI channel 1.
To get the arduinos to send MIDI data read over this guide: http://arduino.cc/en/Tutorial/Midi. I don't send the notes or velocity in hexadecimal. Decimal works perfectly because the Serial.write(); command sends it as a byte.
There are two programs attached in the zip file; one for one ATmega, another for the other.
Attachments
Step 5: Programming the ATmegas
Step 6: Hook It Up! Try It Out!
Step 7: Enclose and Finalize the Project
Step 8: Video Demonstration
Thanks for reading! Happy Building!