Wiring Arcade Controls to a Raspberry Pi GPIO

Building a custom arcade cabinet around a Raspberry Pi is a rewarding DIY project that blends woodworking, electronics, and retro gaming. To establish a connection between your classic microswitch arcade joysticks and buttons and the Raspberry Pi, you can choose between two main methodologies: direct wiring via the General Purpose Input/Output (GPIO) pins, or utilizing a plug-and-play USB encoder board. Direct GPIO wiring offers the lowest possible input latency and requires no extra hardware, while USB encoders simplify the process by handling the hardware abstraction for you. This guide breaks down both approaches, detailing the physical connections and configuration steps needed to bring your custom cabinet to life.

Understanding Arcade Switches and the Ground Loop

Standard arcade buttons and joysticks utilize simple, mechanical microswitches. Each switch features three terminals: Normally Open (NO), Normally Closed (NC), and Ground (COM or Common). For arcade functionality, only the Normally Open and Ground terminals are used. When a button is pushed or the joystick is pushed in a direction, the internal circuit closes, sending a signal to the processor.

Because every button and joystick direction requires a connection to a ground pin, wiring them individually would quickly exhaust the ground pins available on your Raspberry Pi. To solve this, a ground daisy chain is employed. A single, continuous wire connects to the COM terminal of the first button, moves to the next, and continues until all inputs are linked together. The end of this collective chain is then plugged into a single ground pin on the Raspberry Pi.

Method 1: Direct GPIO Wiring

Wiring your controls directly to the Raspberry Pi’s 40-pin GPIO header is highly efficient, but it requires careful attention to the specific pinout mapping.

Physical Wiring Steps

  1. Connect the Ground: Run a daisy-chained ground wire to the COM terminal of every button and joystick switch. Connect the terminating end of this wire to any available GND pin on the Raspberry Pi header (such as physical Pin 6, 9, or 14).
  2. Connect the Signal Wires: Run an individual jumper wire from the Normally Open (NO) terminal of each switch to a specific Broadcom (BCM) GPIO pin.

When choosing your pins, ensure you are mapping to the software’s designated BCM numbers, rather than the physical layout pin numbers. Below is a standard single-player configuration map commonly used by software drivers:

Control Input BCM Component Pin Physical Header Pin
Joystick Up BCM 17 Pin 11
Joystick Down BCM 27 Pin 13
Joystick Left BCM 22 Pin 15
Joystick Right BCM 10 Pin 19
Button 1 (A) BCM 18 Pin 12
Button 2 (B) BCM 23 Pin 16
Button 3 (X) BCM 24 Pin 18
Button 4 (Y) BCM 9 Pin 21
Select (Coin) BCM 14 Pin 8
Start BCM 15 Pin 10

Software Configuration

Because raw GPIO signals do not register as a standard game controller out of the box, you must install software to translate the physical pin changes into virtual keyboard strokes or gamepad events.

Popular packages like retrogame (by Adafruit) or the Linux kernel module mk_arcade_joystick_rpi can be installed via the terminal. These programs run quietly in the background, monitoring the designated pins. When a button press forces a pin to ground, the software registers a state change and maps it directly to a virtual keypress that retro-operating systems like RetroPie or Recalbox instantly recognize.

Method 2: Zero-Delay USB Encoders

If you want to avoid mapping individual GPIO pins, or if you are building a two-player cabinet that requires more inputs than a standard 40-pin header can safely accommodate, a Zero-Delay USB Encoder is the ideal solution.

[ Arcade Button / Joystick ] 
            │ (Quick-Connect Wire)
            ▼
┌──────────────────────────────┐
│   Zero-Delay USB Encoder     │
└──────────────────────────────┘
            │ (Standard USB Cable)
            ▼
┌──────────────────────────────┐
│     Raspberry Pi USB Port    │
└──────────────────────────────┘

Installation Steps

  1. Connect Controls to the PCB: USB encoder kits ship with dedicated wire harnesses. Plug the quick-connect spade connectors into the microswitches, and snap the white plastic terminal block directly into the matching socket labeled on the encoder board (e.g., K1, K2, AU, AD).
  2. Connect Joystick: Most modern joysticks use a single 5-pin wiring harness that plugs directly into a dedicated port on the encoder card. If using individual microswitches for the stick, wire them to the direction ports just like standard buttons.
  3. Plug into the Pi: Use the provided USB cable to hook the encoder board directly into one of the standard USB ports on the Raspberry Pi.

The primary benefit of this configuration method is that the operating system instantly detects the encoder board as a standard USB HID gamepad. There is no need to write code, install custom kernel scripts, or risk shorting out GPIO pins—the software input configuration screen will guide you through mapping your buttons upon the very first boot.