Introduction: Arduino MIDI Bass Pedals

About: "A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, gi…

I've always liked bass pedals. I'm a big fan of the band Rush, and their bass player Geddy Lee. Most of my favorite Rush albums use the Moog Taurus pedals which have become synonymous with their sound of that era. I don't know what it is. The deep, droning sound - that you play them with your feet (name another instrument that is exclusively played with the feet). That they are a synthesizer. Maybe a combination of all three. There is just something special about them. They are not found in everyday music.

A few years ago I bought a Hammond M2 organ off of Craigslist. It had no tubes in the amplifier. In fact, when I went to the guy's house who listed it, it had stuff piled all over it. It was literally buried to where you couldn't see it. He showed me that it at least ran. When I got it home (an ordeal in itself, since it weighs over 300 lbs) and found tubes, got it running and making noise, the bass pedals didn't sound right. They were triggering multiple notes at the same time. I found that 3 of the wires going to the foot pedals were broken, probably from being snagged on something when it was moved. I soldered them back together, put heatshrink tubing over the problem areas and.... had the same problem. I have read or have been told that on this series of organ the pedals don't sound very good to begin with. So I extracted them. Snipped the 13 wires connecting them to the tone generator.

And they sat on my shelf for over a year. They were heavy, had sharp metal edges, old cloth-covered wire. There was not much incentive to mess with them. I had the idea of making bass pedals out of them, and in my mind I was looking for some kind of old suitcase I could house them in, with holes cut in it for the keys to stick out. I never found one.

One day, a few houses down, in the trash at the side of the road, was a kid's toy "grand" piano. It was beat up, chips in the wood, marker on the yellowed keys, dusty, musty. It made sound though, kind of a xylophonish sound made by plastic hammers banging on metal rods. I brought it home and proudly showed my wife the great prize that I had saved from the landfill. She frowned disapprovingly. I opened it up to make sure it wasn't full of bugs, and then it sat on my shelf for many months waiting for a purpose.

Then one day the two pieces were sitting on the shelf next to each other, and a lightbulb appeared over my head. I thought "What if....?"

Since this was a fairly easy project of jamming two things together (with a little bit of wiring added in) the first step was to see if they would even fit together. The guts of the piano would have to be torn out and cleaned up.

Step 1: Gutting the Piano

After removing the lid and "Kiddy Keys" faceplate and setting it to the side, a couple of screws and some nails held the metal rods in place. The metal rods were all attached to one board and came out as one piece, to be saved for a later project. The plastic keys and hammers floated in place and were unceremoniously tossed in the trash.

This left a couple of "cheek blocks" (to steal an organ term) on the left and right which were pried out with screwdriver and hammer. The wooden teeth that the piano keys rested on was easily pried out with pliers. This left a nice open and clean space to put the pedals.

Step 2: Making the Pedals Fit

As you can see in the first pic, the pedals didn't go in without a fight. There was some heavy overlapping metal that had to be dealt with. I bought a pair of aircraft aluminum snips that are pretty amazing. They cut through the metal like refrigerated butter. Excess rough edges were sheared off with a metal file.

That got the pedals in almost all the way, but they didn't quite go deep enough into the case due to the shorter rounded back edge of the piano case. After some more snipping, filing, and ultimately hammering, they slid right in to the point where the faceplate could be reused with nothing majorly sticking out. It was a great feeling as they satisfyingly *kachunked* into place and fit like a glove.

Step 3: Cleanup and Paint Job

I removed all of the plastic "ribs" that were attached to the solid metal pedal bars and gave the black metal a good rubdown with some WD-40. The 50 years of dust was quite attached, but eventually came off enough where I was happy with it. I wasn't trying to make it look perfect since the piano case was kind of beat up to begin with. I also gave the plastic ribs a good wiping off with a wet cloth.

I used some glossy orange RUST-OLEUM spraypaint (ALSO BONDS to PLASTIC!) and ended up using the whole can since I wanted a durable surface. I did 2 coats but eventually ran out during the second coat. It got a nice smooth finish except where I went a little heavy.

Step 4: Making the Pedals Work (Part 1)

There are few specific resources on the Internet for exactly how these M2 pedals are wired. I did find that the M series (M1, M2, M3) all use the same pedals, which helped. I had the original Hammond M2 schematic, which helped some, but I was still baffled as to how exactly they would be wired to an Arduino. I had 12+1 old wires coming out of the pedals, and there were small metal "bridge" wires going between each keycomb. Really a fascinating mechanical and electrical design (the M2 organ was designed in 1952). There was also some kind of copper tube and switch mechanism that "clicked" every time you pushed a new pedal (which I found out was the latch feature that holds the last note you played).

I solicited the advice of the wonderful HAMTECH (Hammond technician) mailing list that I lurk on. In my plea for help I admitted I didn't understand how the wiring worked despite sitting and staring at it for hours, but that I wanted to keep these beautiful switches rather than use something more modern. I received several different replies:

"It can be done, but it won't be as obvious how to do it because of the slightly odd way they are wired. My rudimentary understanding of the circuit is that all tones are nominally shorted and by pressing a pedal, you un-short it so that it can sound. Consequently, when more than one pedal is pressed, the tones are combined *in series* rather than *in parallel*. There is also a latch so that the slow decay and sustain features can work (The M3 has a sustain, but I don't think the M2 does.)"

"I would leave the original contact system of the M-100, and install 13 new microswitches, or 13 fork photocells, and blinders. You could have a look at the 4532 CMOS IC, which is often used in organ pedal arrangements, because you can make a lowest or highest key priority."

"What you could do is to ground one end of the series of switches, use apull-up resistor to Vcc on the other end, then sense the bridge wire between each switch to determine which pedal has been pressed, if any.That should avoid re-wiring your switch bank."

All of these answers made my head spin. And then out of the blue, I got the reply I needed!

Step 5: Making the Pedals Work (Part 2)

I received a critical email from Michael Smokowicz of Trek II, modern-day makers of great Hammond add-ons and accessories.

"Hello Ron,

I don't think we've spoken before. My name is Michael and I've had some experience (though not very recent) working with M-100 pedal switches. I see that you are working on a similar project and I thought this information might be of interest / benefit to you. (I believe this information will translate more or less intact to the 12 note M-2 pedal switch... by ignoring all references to the high C pedal.)

As you know the M series pedal contacts are:
A) Mechanically configured with a latching mechanism to hold open the contact for the last note played.
B) Strung in series.
C) Normally closed.


A) It is possible to easily (and non-destructively) disable the latching mechanism as follows:

Depress any pedal and note the pivot arm that moves against the felt bumper located between the E & F pedals. Using a nylon ziptie through the eyelet holes in the felt bumper, secure the pivot arm against the bumper so that it is immobile. This will convert the contacts to momentary action.

B) As previously mentioned, the contacts are strung in series. It would probably be preferable to have them wired so that the individual contacts make to a common bus. You can save a little bit of work by utilizing half of the jumpers that already exist between switches (and removing the other half):
If you haven't already, cut the pedal switch harness from the switch contacts.
Cut the jumpers going between the following pedals: C# & D, D# & E, F & F#, G & G#, A & A#, B & high C
Using short lengths of hook-up wire, connect the remaining jumpered switch terminals together. If applicable, also connect one of the high C contacts to this group. This is now your common keying bus.
(There should be one empty switch terminal on each of the pedal's switches.)


C) The fact that the contacts are normally closed can be addressed in software.... or by connecting the common bus to logic 0 (ground?) and using a pull-up resistor on each line. When the contact associated with the played pedal opens, the pull-up resistor will provide a logic 1 for that note to your system.

Note: The pair of switch contacts located on the side of the pedal assembly that used to close when any pedal was pressed will not be utilized.

Good luck,
Michael


Michael Smokowicz
Trek II Products"


This was IT! This couldn't have been described in more common terms and instruction. Yet I still hesitated. For several months. Step A was a no-brainer. Step B, I understood the concept of there being a common bus that all contact switches are on, preferrably to ground. But cutting the jumpers between the pedals was scary.. as I sat and stared at them, I realized I was still having trouble "getting" it. Eventually I took a deep breath and started following the directions exactly as stated, cutting the jumpers between each of the listed notes. Halfway through the list it became apparent exactly why I was doing these particular cuts. Sometimes you have to see it to understand. Thank you, Michael!

Step 6: Wiring to Arduino

I used an Arduino Pro Mini purchased from Sparkfun. The brown wire is what I used for jumping between the unconnected switch terminals to form the common bus. The signal wires going from the switches to the Arduino came from CAT5 network cables and I used a twisted pair for each of the 12 pedal switches. After it was all wired cleanly to the ground (common bus) and 12 inputs on the Arduino I used small cable ties to clean everything up.

I drilled a 1/2" hole in the back of the piano case for a MIDI connector (from Skycraft) and wired it to the TX pin of the Arduino, as well as 5V (with a resistor). Now to start programming..

Step 7: Programming (Reading and Testing the Pedal Switches)

Whenever I start a new hardware project and I'm ready to write the code, I will always test all the inputs and outputs with a little sketch that just spits all their values out to the serial monitor. That way I can see that everything is working before even starting the real code. Saving this project-specific code for later comes in handy as there are times where I will have to upload it again, either because something isn't working, or because I've added another switch/knob that needs initial testing. Using serial monitor to debug and test is always tricky with MIDI applications, because they share the Serial TX port on the Arduino. (only one or the other can use the serial port) It requires commenting out your Serial communication lines and uncommenting the MIDI lines, or vice versa. You want to make sure your output is right before you start sending MIDI messages, since you will be somewhat blind unless you use a MIDI monitoring application.

byte pedalPins[12] = { 2,3,4,5,6,7,8,9,10,15,17,16 }; // the pins on the Arduino each pedal are on
byte lastPin[12] = { 0,0,0,0,0,0,0,0,0,0,0,0 };
byte currentPin[12] = { 0,0,0,0,0,0,0,0,0,0,0,0 };

for (int x=0;x<12;x++) {
currentPin[x]=digitalRead(pedalPins[x]);
if (currentPin[x]!=lastPin[x]) { // CURRENT AND LAST PIN DO NOT MATCH, AN EVENT OCCURRED

lastPin[x]=currentPin[x];
if (currentPin[x]==0) { Serial.print("Pedal "); Serial.print(x+1); Serial.println(" Up"); }
if (currentPin[x]==1) { Serial.print("Pedal "); Serial.print(x+1); Serial.println(" Down"); }
};
}
}

When you are working with a momentary switch, in order to avoid repeated triggers of the switch being pushed as the loop runs over and over, we usually would store the "last" value that the switch had and compare it to the current value that was just read. Then we can see that the two values don't match, so we know that something changed. Think of this change as an event where something needs to happen. In the case of the pedals it is the logic changing from 0 to 1, or 1 to 0 (switch closed or open). Based on the direction of the event you would do different actions, like sending a MIDI Note On or Note Off message. In the above code we are storing 12 separate current and last values, one for each pedal. This allows us to hold down pedal #1, and then push pedal #5 while we are holding #1 because they are all independently tracked. The importance of this for MIDI is that you need to send corresponding Note Off messages every time you trigger a note with Note On. If you don't, whatever synthesizer you have connected will just keep playing the same droning notes and eventually you will have 12 notes all On at the same time with nothing to say stop playing the note. They will play forever until you reset your synthesizer.

The above snip of test code works, but it's very bouncy with repeated up/down triggers as the pedal is pushed or let go (particularly when you take your foot off, as the pedal literally bounces up because of the spring mechanism). Let's debounce it in the next step.

Step 8: Programming (Debouncing the Switches X 12)

Here is our debounced loop. Note that we are also storing the debounce times as 12 independent values:

int buttonState[12]; // the current reading from the input pin
int lastButtonState[12] = { LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW };
long lastDebounceTime[12] = { 0,0,0,0,0,0,0,0,0,0,0,0 }; // the last time the output pin was toggled long debounceDelay = 50; // the debounce time; increase if the output flickers

for (int x=0;x<12;x++) {
currentPin[x] = digitalRead(pedalPins[x]);
if (currentPin[x] != lastButtonState[x]) {
lastDebounceTime[x] = millis();
}

if ((millis() - lastDebounceTime[x]) > debounceDelay) {
if (currentPin[x] != buttonState[x]) {
buttonState[x] = currentPin[x];
if (currentPin[x]==0) { Serial.print("Pedal "); Serial.print(x+1); Serial.println(" Up"); }
if (currentPin[x]==1) { Serial.print("Pedal "); Serial.print(x+1); Serial.println(" Down"); }
}
}

lastButtonState[x] = currentPin[x]; }

}

Works great! No repeating triggers now. Just clean up and down events. Let's make MIDI!

Step 9: Programming (MIDI Output)

The change from serial monitoring to MIDI is very easy. First, import the MIDI library to your project. Remove or comment out the Serial.begin statement from the setup loop. Add the following to the setup loop:

MIDI.begin(1);

This initializes the MIDI library. Here is our new loop with MIDI commands:

if (currentPin[x] != buttonState[x]) {
buttonState[x] = currentPin[x];
if (currentPin[x]==0) { MIDI.sendNoteOff(basenote+x,127,1); } // PEDAL UP, NOTE OFF
if (currentPin[x]==1) { MIDI.sendNoteOn(basenote+x,127,1); } // PEDAL DOWN, NOTE ON
}
}

The parameters of the sendNote commands are (Note Number to Send, Velocity (volume), Channel). We know from looking at our MIDI Note Chart that C on octave 1 is number 36. Octave 0 is just a little low to be useful. So in our variables for this program we set a basenote:

int basenote=36;

This variable could be used to adjust what octave your bass pedals play on.

And that's all we do in this program. Cleanly read the pedals to see what is pushed, send a MIDI Note On message with the corresponding pedal, and when the pedal is lifted send a corresponding MIDI Note Off.

Step 10: Finishing Touches

I used wood glue to attach some scrap wood to replace the cheek blocks I tore out. These are what the lid of the piano case get screwed to.

To avoid painting the faceplate, I used a Moog bumper sticker I got while visiting the Moog Music factory in Asheville, NC. It was black and blended in, covering up the old "Kiddy Keys" logo. Looks pretty decent and pays homage to the original! I notched out a small rectangle of wood from the bottom of it so it fit cleanly over the pedals, and attached 2 magnets to the back with glue. It sticks to the metal case of the pedal assembly with the magnets.

I also added a power switch to the left side and a 9V battery holder inside the case, so that it could be moved around and operated wirelessly.

Step 11: Demo Video

Here's a quick video of the pedals hooked up to an iPad running Animoog. I didn't have great bass speakers at the time to make a proper demo video, so I used some more trebly patches.