Using Hall Effect Sensors to Magnetically Detect Organ Pedal Position
Magnetism may be the closest thing there is to magic (microcontrollers being a close second). Here’s a story that combines both. And also, Bach. J.S. Bach, that is. An organ’s pedals behave the same as a keyboard, giving the organist one more “input device” (Figure 1).
Figure 1: Organ pedals are laid out just like a musical keyboard. Think you could play Chopsticks on them? (Image source: Michael Dunn)
That said, the discussion here applies to all sorts of pedals. In fact, it applies to almost any sort of switching or position sensing application you can think of. Read on.
My organ background (feel free to skip)
Since my teens, I’ve wanted to possess a pipe organ, or a reasonable facsimile thereof—mainly to play the magnificent music of J.S. Bach. Can you imagine how Bach would sound on the magnificent Orgue de l'église Saint Germain l'Auxerrois in Paris (Figure 2)? Since cost and space rule out the former, electronic organs have been on my mind for decades, from my early, all-analog monster designs, to later digitally generated additive synthesis concepts. Suffice it to say that, apart from acquiring keyboards and a pedalboard, these plans went nowhere. Sure, one could also buy an electronic organ, but none were to my liking, and where’s the fun in that anyway?
Figure 2: No room for this, and besides, it’s not for sale. (Image and source: Orgue de l'église Saint Germain l'Auxerrois, Paris, via Wikipedia.org)
But in recent years, programs such as Hauptwerk (the German name for one of an organ’s keyboards, but you knew that, of course) have developed into remarkable engines for recreating the sounds of real organs using sampling technology. I confess it’s time for me to scrap my dreams of designing an instrument from scratch.
Sensing pedal position
Having decided to use commercial software for organ simulation, this left me to build the console—including two or three keyboards and a pedalboard. I acquired those mechanisms many years ago, and they contain no switching/sensing of any sort. What to do?
The primitive solution would be to use a switch of some sort (or bare contacts) for each key and pedal. This precludes velocity and position sensing, though. You may wonder why—for an organ—I’d care, but it turns out that classic, all-mechanical organs do respond to touch (not to the extent of, say, a piano, of course).
This still left several switch options, including staggered pairs of contacts (measuring the time between one opening and the other closing to get velocity), optical, pressure, capacitive, and inductive, but I found myself drawn to magnetic sensing. A linear Hall effect sensor seemed like the way to go, offering low cost, low power, mounting options, and position sensing. There is a wide variety to pick from, but I ended up using 32 Honeywell SS39ET Hall effect sensors mounted on small break-out boards (Figure 3). Only power is hooked up at this point, using PRT-08024 insulated wire from SparkFun. Would you believe, I had a summer job at Honeywell circa 1979? It was my first exposure to the Hall effect. It was used in keyboard switches (computer keyboards, not musical instrumentation).
Figure 3: View of five Honeywell SS39ET Hall effect sensors mounted on small break-out boards. As shown, only power is hooked up at this point. (Image source: Michael Dunn)
One concern I had was magnetic crosstalk between pedals. A quick test showed that moving an adjacent magnet caused only about a 2% output change in the sensor under test, which is acceptable for this application. To provide the required magnetic fields, I used ½ inch diameter 8184 magnets from Radial Magnets Inc. mounted into the pedals (Figure 4). For more sensitive use cases, magnetic shielding might be necessary. Another option would be to fix the magnets and move the sensors if you can live with wire flexing.
Figure 4: Magnets mounted into the pedals provided the required magnetic field to stimulate the Hall effect sensors. (Image source: Michael Dunn)
Microcontroller magic
Next, I needed to choose a microcontroller—in this case, on a small board. For a production run of one, why reinvent the wheel (or pc board)? The most significant aspect of my choice was: “How did I want to program the processor?” The default answer, “in C”, came to mind, either in the Arduino environment, or using the manufacturer’s development support. But I’d been hearing good things about MicroPython, and as a fan of regular Python, I decided to give it a try. I ended up choosing Adafruit’s 3857 Feather M4 Express board, which sports a Microchip Technology ATSAMD51J19A-AU-EFB 120 MHz Arm Cortex-M4 core, along with a good set of peripherals. Adafruit has its own version of MicroPython—called CircuitPython—which I’ll be using.
The downside of this language choice is speed. Python, being interpreted instead of compiled, runs at only a few percent the speed of C (your results will vary depending on factors like library usage). Given the real-time nature of this project, I may have to abandon Python, but that’s a topic for a future blog. It will be a great learning experience either way.
What exactly do we need the microcontroller to do? First and foremost, it will be scanning the Hall effect sensors, translating their readings to Musical Instrument Digital Interface (MIDI) note velocity, and sending that data over USB to the host computer running the organ software.
Second, it will receive serial MIDI data from the two or three keyboards, which will also be funneled through the USB connection. I’ve decided, for now at least, to press some old synthesizers I have lying around into service, rather than take on the much bigger project of wiring up 168 key sensors. Besides, the closer spacing of the keys compared to the pedals means crosstalk could become an issue. Perhaps optical reflective sensors would be the way to go here. I’ll probably never move this circuit to anything more permanent than a breadboard. In its current form, two Texas Instruments 74HC4067 16-to-1 multiplexers route one of the 32 sensor outputs to the microcontroller (Figure 5). The three ON Semiconductor H11L1 optocouplers are required for the MIDI inputs (Figure 5).
Figure 5: From left to right: The Feather M4 microcontroller board, the two 74HC4067 CMOS analog multiplexers, and the three H11L1 logic level optocouplers for MIDI input. (Image source: Michael Dunn)
Three CUI Devices SD-50SN DIN jacks will be wired to the optocoupler inputs to serve as standard MIDI inputs (Figure 6).
Figure 6: The standard MIDI DIN jack since, well, forever. (Image source: CUI Devices)
One great system feature the processor provides is auto-calibration. Due to variations in the Hall effect sensors, magnets, and positioning, each sensor will generate a specific output voltage range, roughly, from mid-supply when the magnet is furthest away, moving through almost a volt as the pedal is depressed. By going through a calibration procedure where each pedal is depressed, the microcontroller will store min/max values for each in flash memory.
Conclusion
After sitting on my pedalboard (figuratively, not literally) for decades, I’m very pleased to finally be bringing it to life. In doing so, I’m learning more about magnetic sensors, the latest in microcontrollers, and saving tons over finding and buying a new MIDI pedalboard (believe me, not a common item). Most Hall effect sensors in the wild are probably simple switches, but linear ones make for versatile sensing solutions.
We’re also living in a golden age of microcontrollers, including many low-cost dev boards and great development environments. I’ll soon see whether CircuitPython is suitable for this project, or if I’ll have to choose a different solution due to execution speed.
All that remains is to finish wiring up the hardware, then dive into the software. I’ve already experimented successfully with the CircuitPython MIDI & USB libraries, though I did run into a few glitches, which were solved with help from Adafruit’s support forums. I hope to return soon with a full report on the finished system, focusing on the firmware side of things.
Related Articles:
Develop Real-Time Microcontroller-Based Applications Quickly Using MicroPython, Jacob Beningo, 2017
Bach for Engineers, Michael Dunn, EDN, 2013

Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.
Visit TechForum