Learn

DIY rhythm game controllers: a guitar and a dance pad

Intermediate

Or see every lesson.

  • 261parts on the bench
  • 31boards running now
  • 1.00xreal time, on every board
Pro Micro: a guitar controllerlive0.000 s 0.00x
Press Run, hold a fret, then click a strum switch
Hold an arcade button for a fret, then click a lever switch to strum. Watch the Serial Monitor.

Rhythm game players build their own controllers for the same reason fight stick players do: the stock hardware wears out, it is not quite the shape they want, or it was never made for the PC. A guitar with keyboard switches for frets, a dance pad that does not slide across the floor, a rebuilt controller with a new board inside. The electronics behind all of them are small and the same few ideas come up again and again.

The circuit above is a guitar controller on a Pro Micro in Mokxi: five fret buttons, a strum bar made of two lever switches, a whammy pot, a start button and a tilt switch for star power. Press Run, hold a fret and click a strum switch, and the Serial Monitor names the chord. A second built-in, the dance pad, reads four force sensing panels and lights a lamp under each.

One thing up front: Mokxi does not simulate the USB connection to your PC. Both sketches use the Arduino Joystick library’s API, and in the simulator each gamepad report prints as a [Joystick] line on the Serial Monitor instead of going over USB. Everything before that point runs for real: the switches, the debounce, the calibration and the thresholds. Flash the same sketch to a real Pro Micro and it is a game controller.

Want the step-by-step version? The lesson "Build a guitar controller" walks through this with checkpoints.

Open the lesson

Why a Pro Micro

Most Arduino boards reach the computer through a separate USB-to-serial chip, so the PC only ever sees a serial port. The ATmega32U4 on the Pro Micro, the Leonardo and the Micro has USB on the chip itself, and the sketch decides what the board is. That is why the community Arduino Joystick library runs on these boards and not on an Uno; its documentation says so plainly.

Many guitar builds also use ready-made firmware with a configuration tool rather than writing a sketch, and some use other boards entirely. The wiring ideas below are the same either way: one leg of every switch to ground, the other to a pin with its pull-up on.

Frets and a strum bar that never double-strums

A guitar plays when you strum with frets held, not when you press a fret, so the sketch names the chord at the moment of the strum. The strum bar is two lever microswitches under one bar, one for up and one for down, which is how many guitars are built inside.

Microswitches bounce: for a few milliseconds after they close, they open and close again. A sketch that reads them fast sees one strum as three notes. The usual Arduino debounce waits for the switch to settle, which adds the wait to every note. The example accepts a change at once and then ignores that pin for 15 milliseconds, so the bounce is thrown away and the strum is not delayed. The lever switches in the circuit have their bounce turned on, so you can see one strum print one line.

In the report the frets are buttons and the strum bar is a hat switch, 0 degrees for up and 180 for down, the way many console guitars send it. A game maps them once in its controller settings.

The strum lockout, from the example sketch
bool down = digitalRead(pins[i]) == LOW;
if (down != held[i] && now - changedAt[i] >= STRUM_LOCK_MS) {
  held[i] = down;       // take the strum at once
  changedAt[i] = now;   // then ignore the bounce
}

A whammy you can calibrate, and star power from a tilt switch

The whammy is a 10k pot with its wiper on A0. A real bar rests against a stop that does not read exactly zero, and old pots wobble a count or two, so the config block has two calibration readings, rest and full, and a deadzone near rest. Turn on WHAMMY_DEBUG to print the raw reading while you set them.

Star power is the neck going up. A ball tilt switch closes while it stands upright and opens as it tips, so the example mounts it upright while the guitar is level and turns the open switch into a button. The ball rattles as it rolls, so the tilt has a longer lockout than the frets.

A dance pad on force sensing resistors

A dance pad is four big buttons you stand on. Many DIY pads use force sensing resistors (FSRs) under each panel: thin, cheap and with no moving parts. Open firmware written for FSR pads, such as the FSR project for Teensy and Arduino boards, adds a web page for tuning each panel, which tells you how much the tuning matters.

The dance pad built-in reads each FSR on an analog pin with the chip’s pull-up as the other half of the divider, and turns the reading into pressure. Every panel has two thresholds: it turns on above PRESS and off only below PRESS minus RELEASE_GAP. With one threshold, a foot resting near the line flickers the arrow on and off, which a game reads as a burst of steps. The gap is the cure, and the example has one PRESS value per panel because real panels never match.

The internal pull-up varies from chip to chip, so the sketch has a switch for a fixed pull-up resistor per panel, which many builds use for a steadier range.

From the simulator to a real controller

Each sketch keeps everything you would change at the top, under Make it yours: pins, left-handed play, lockouts, calibration and thresholds. Change them, press Run, and see the effect before you solder anything.

The step Mokxi cannot check is the last one: whether your PC or console accepts the board, and how the game maps it. That depends on the library or firmware and the host. The wiring and the logic you proved here are what you build.

Questions

Can an Arduino Uno be a guitar controller?

Not as a USB gamepad on its own. The Uno’s main chip has no USB, so the Joystick library does not run on it. Use a board with an ATmega32U4, such as a Pro Micro or Leonardo.

Does Mokxi simulate the USB gamepad?

No. The simulated Pro Micro models its USB as a serial connection, so each report prints as a [Joystick] line on the Serial Monitor. Flash the same sketch to a real board for USB.

Why does my dance pad arrow flicker?

A single threshold makes a resting foot cross it again and again. Use a press threshold and a lower release threshold, as the example does with RELEASE_GAP.

Is there a course?

Yes. Build a guitar controller is three short lessons on this circuit: the frets and strum bar, the whammy and star power, and your own config.

Build this for real

Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.