Improving an Old Pinball Machine with an ESP32 and New Sound Effects

See how element14 Presents' Mark Donners upgraded a pinball machine from 1972 with immersive sound effects thanks to an ESP32.

Evan Rust
11 months agoGaming / Music

The existing pinball machine

Electric pinball machines have been around for over 90 years and have undergone several massive changes throughout their evolution. Perhaps the largest was the move from mechanical-style computers that used relays and gears to microprocessors and solid-state MOSFETS. Element14 Presents host Mark Donners was recently sent one such pinball machine from a friend for repairs that was made in 1972. It features an assortment of lights, bumpers, and even a mechanical score counter, but sound effects are noticeably absent, which prompted Donners to add them.

Protecting the microcontroller

Older pinball machines run at relatively high voltages, often ranging between 12 and 48 volts or even higher. These high currents coupled with sparks from the relays mean whatever microcontroller is connected to the system requires adequate electrical and magnetic isolation. For this reason, opto-isolators are often chosen since they physically decouple electrical signals from one another through the use of an internal LED, receiving phototransistor, and some simple amplification to drive an output. Donner's bank of isolators on a piece of protoboard allows for up to eight distinct triggers from the various outputs on the pinball machine.

How to play MP3 files?

Now that the signals from the machine could be read, the next challenge was how to play sound effects based on a brief trigger. Donners had a few choices: a custom 8-bit audio players based on an Arduino Nano, a SparkFun Audio Trigger board, an inexpensive audio player module, or an ESP32-based MP3 player. The last option was selected since the ESP32 has low latency between receiving a trigger and playing the corresponding audio file, support for high-quality I2S sound output, and has the potential for adding Wi-Fi/BLE connectivity in the future.

Because the power coming from the DAC is only 3W, an additional layer of isolation and amplification was needed. The audio transformer module translates the incoming I2S signal into an audio waveform and helps to minimize the digital noise coming from the DAC. Subsequently, the amplifier takes the lower-power audio signal and boosts it high enough to drive a speaker. In this case, Donners sought a non-destructive way to play audio, so he opted for a resonator that turns the entire pinball machine's chassis into the speaker's diaphragm.

The firmware

On the software-side, the ESP32 begins by initializing the SD card and its I2S pins for communication with the audio transformation module. Next, it configures the pins connected to the opto-isolators' outputs as inputs before entering into a loop. In here, each pin is checked for a trigger signal, and if one is found, the audio library causes the accompanying sound file on the SD card to begin playing.

Playing some pinball

After getting several of the bumpers and switch banks connected to the opto-isolator inputs, Donners tested out his newly improved pinball machine by playing a couple of games on it. As can be heard in his video, each sound effect is played with minimal latency once a switch is activated, and because everything is stored on an SD card, sound files can be easily swapped to new effects at any time.

Evan Rust
IoT, web, and embedded systems enthusiast. Contact me for product reviews or custom project requests.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles