Wiki · Features

Build a DIY Taiko Drum Controller (Arduino + Piezo)

Build a DIY taiko drum controller with Arduino and piezo sensors: wiring diagram, parts list, 3.3 V / RP2040 notes, tuned sketch and a browser test panel.

☰ Conteúdo

Short answer: a DIY taiko drum controller is four piezo discs wired to an Arduino Pro Micro, Leonardo or RP2040 board that acts as a USB keyboard sending D, F, J and K. This page has the wiring diagram, parts list, 5 V and 3.3 V protection, a tuned sketch and a troubleshooting table; then check every pad in the test panel on the play page before you play.

The trial on the play page is the Z-DON web game. This page explains how to connect a DIY drum or controller box, and what to do when hits are missed or feel off.

Build path at a glance

Follow the sections in this order. Each step links to its section.

  1. Keyboard mapping and connecting the controller
  2. Wire the four piezos
  3. Example sketch and settings
  4. Flash the board
  5. Test panel: start here
  6. Read the results and tune
  7. Latency budget and input latency compensation
  8. Troubleshooting by symptom
  9. Gamepad and USB drum mode

Keyboard mapping

Key Action
D Left ka
F Left don
J Right don
K Right ka
Esc Pause

Connecting a controller

  • Controller box / DIY drum (most reliable): switch the controller to its keyboard-emulation mode so it sends D, F, J and K. The trial then sees ordinary keyboard input.
  • Phones and tablets: turn the device sideways and tap the on-screen touch drum, which the game shows by itself.
  • Standard gamepad or USB drum: see Gamepad and USB drum mode below.

Keeping keyboard focus in the game

Keys only count when they reach the game, so click the game once before you start. If keyboard focus leaves the game (for example you clicked elsewhere on the page), a "click the game to continue" hint appears. Click the game, or press D, F, J, K, Space or Esc outside it, and focus returns. When you come back with a key press, that first press is lost.

Wiring a four-piezo box

The example sketch below expects one piezo disc per drum face, wired to the analog pins A0-A3 of a Pro Micro or Leonardo, and the board plugged into the PC over USB. The diagram shows a 5 V board; if your board runs at 3.3 V (RP2040 / Raspberry Pi Pico, a 3.3 V Pro Micro, ESP32-S3), use the 3.3 V protection described below instead of the 5.1 V Zener. The diagram shows one identical channel repeated four times (P1-P4 are the piezos; D, F, J, K are the keys each pad sends).

The wiring for four pads on a Pro Micro or Leonardo, matching the sketch's pin array {A0, A1, A2, A3} and key array {'d', 'f', 'j', 'k'}: P1 to A0 sends D, P2 to A1 sends F, P3 to A2 sends J and P4 to A3 sends K.

Wiring diagram for a Pro Micro or Leonardo: four piezo channels P1-P4, each with a 1 MΩ resistor, a 5.1 V Zener diode and a 1-10 kΩ series resistor, to analog pins A0, A1, A2 and A3, which send D, F, J and K. All grounds join GND; USB goes to the PC.

The same channel in detail, with the optional parts. In diagram A the clamp is a Zener (5.1 V on a 5 V board, 3.3 V on a 3.3 V board); in diagram B it is two Schottky diodes, one from the signal line to VCC (3V3 on a 3.3 V board) and one from ground to the signal line, which clamps more sharply and suits both voltages. In both, the 1-10 kΩ series resistor sits between the piezo node and the analog pin.

Diagram of one piezo channel. A: the piezo, a 1 MΩ resistor and a Zener diode (5.1 V or 3.3 V, cathode on the signal line) in parallel between signal and ground, then a 1-10 kΩ series resistor to analog pin A0; ground to GND. B: the same, but with two Schottky diodes as the clamp, one from the signal line to VCC or 3V3 and one from GND to the signal line.

  • Piezo: the ceramic (usually red) wire goes to the signal line, the brass disc (usually black) wire goes to ground. Polarity does not matter for the sketch, but this way the Zener below clamps the right swing.
  • 1 MΩ resistor across each piezo: gives the charge a path to ground, so the reading falls back to idle after a hit. Without it the signal drifts and hits are missed or doubled.
  • Input clamp (optional but recommended): match it to your board's voltage. A hard hit can produce a voltage far above the supply, and the ADC pin must never see more than the board's supply voltage. A Zener rated above the supply does nothing for the pin.
    • 5 V boards (Pro Micro / Leonardo at 5 V): a 5.1 V Zener, cathode (the banded end) on the signal line and anode on ground; or two Schottky diodes (one from the signal line to VCC, one from ground to the signal line).
    • 3.3 V boards (RP2040 / Raspberry Pi Pico, 3.3 V Pro Micro, ESP32-S3): do not use the 5.1 V Zener, because it lets the signal reach about 5 V, more than a 3.3 V pin tolerates. Use a 3.3 V Zener instead (such as 1N4728A or BZX55C3V3), or, better, two Schottky diodes (such as BAT85 or 1N5819): one from the signal line to 3V3 (anode on the signal line) and one from ground to the signal line (cathode on the signal line). A Zener starts to conduct gradually somewhat below its rating, which can flatten large hits; the Schottky pair clamps more sharply.
    • Series resistor (recommended on every board, essential on 3.3 V): put 1-10 kΩ between the piezo node (where the 1 MΩ resistor and the clamp sit) and the ADC pin. It limits the current the clamp has to carry. The ADC input draws almost no current, so it should not noticeably change the reading, but re-check your lightest hit.
  • Common ground: all four piezo ground legs join one ground wire to the board's GND pin.
  • USB: the board's USB connector goes straight to the PC; no extra power is needed.

Parts list

Qty Part Note
4 Piezo disc (27 mm or 35 mm) one per drum face
1 Arduino Pro Micro or Leonardo (ATmega32U4), or an RP2040 board (see below) acts as the USB keyboard; check whether your board runs at 5 V or 3.3 V
4 1 MΩ resistor, 1/4 W across each piezo
4 5.1 V Zener diode (such as 1N4733A) optional clamp for 5 V boards only; or 8 small Schottky diodes (such as 1N5819 or BAT85) to GND and VCC
4 3.3 V Zener diode (such as 1N4728A) optional clamp for 3.3 V boards; better: 8 small Schottky diodes (such as BAT85) to GND and 3V3
4 1-10 kΩ resistor series resistor before the ADC pin; recommended, essential on 3.3 V boards
1 USB cable that fits the board (micro-USB or USB-C) data cable, not charge-only
- Hookup wire, solder, enclosure

Using an RP2040 (Raspberry Pi Pico)

An RP2040 board can also act as the USB keyboard, but its pins run at 3.3 V and several details differ from the Pro Micro. The example sketch has not been verified on RP2040 hardware, so treat this as a starting point and check the core's documentation. Diagram for a Raspberry Pi Pico, drawn exactly as the sketch uses it (A0-A3): in the Arduino-Pico core A0, A1 and A2 are GP26, GP27 and GP28, so pads P1-P3 work. A3 is GP29, which on a Pico is wired inside the board to the supply voltage and has no pin, so the fourth pad (dashed) cannot be read; see "Analog pins" below for the board and ADC options. The clamp is the 3.3 V version.

Wiring diagram for a Raspberry Pi Pico: three piezo channels P1-P3, each with a 1 MΩ resistor, a 3.3 V Zener diode and a 1-10 kΩ series resistor, to ADC pins GP26, GP27 and GP28 (A0, A1, A2), sending D, F and J. The fourth channel, to GP29 (A3, internally VSYS divided by 3, no header pin), is drawn dashed and crossed out because it cannot be read on a Pico. All grounds join GND; USB goes to the PC.

  • Protection: use the 3.3 V clamp and the series resistor above. RP2040 pins are not 5 V tolerant and a 5.1 V Zener is not enough. Keep every piezo node within 0-3.3 V (the ADC reference is the 3.3 V rail) and never connect it to VBUS or VSYS.
  • Core and USB stack: install the Arduino-Pico core by Earle F. Philhower, III (Arduino IDE boards manager), select your board, then in the Tools menu keep USB Stack at the default "Pico SDK" (the TinyUSB that ships with the Pico SDK). That stack provides the core's Keyboard.h (Keyboard.begin() / press() / release(), the same calls as the sketch) and the USB Serial used by TUNE_SERIAL. The "Adafruit TinyUSB" option is a different stack with its own HID classes, and "No USB" removes the USB device entirely; the sketch's Keyboard.h calls are not meant for either. Menu names can change between core versions, so check the core's documentation. For the first upload, hold BOOTSEL while plugging the board in; later uploads reset the board automatically.
  • Analog pins (a common trap): the RP2040 chip has four ADC inputs, GP26-GP29, but a Raspberry Pi Pico breaks out only GP26, GP27 and GP28 (A0-A2 in the core). The fourth channel (A3 / GP29) is wired on the board to a measurement of the supply voltage, not to a pin you can use. A plain Pico therefore has only 3 usable analog inputs and cannot read 4 piezos directly; if you set the sketch's pins to A0-A3 on a Pico, the fourth pad never fires. Your options: (1) pick an RP2040 board that breaks out all four ADC pins (some Adafruit Feather and Seeed XIAO RP2040 boards do; check the pinout of the exact board you buy); (2) add an external ADC, which must be fast, because the sketch needs thousands of samples per second per pad (an SPI ADC such as an MCP3008 is workable; an I2C ADC limited to about 860 samples per second, such as the ADS1115, is too slow for a 2 ms peak wait); (3) use an analog multiplexer in front of one ADC pin, which shares one sample rate between the pads and needs a settling delay after each channel switch. Options 2 and 3 need extra wiring and code that the example sketch does not include.
  • Resolution and constants: the RP2040 ADC is 12-bit (0-4095), while the sketch's constants are on the 0-1023 scale (the core's analogRead() returns 10-bit values until you call analogReadResolution(12)). The sketch therefore sets ADC_SCALE to 4 under #if defined(ARDUINO_ARCH_RP2040) and calls analogReadResolution(12) in setup(). Only the two absolute constants change: MIN_THRESHOLD 30 becomes 120 and NOISE_MARGIN 20 becomes 80. NOISE_MULT, XTALK_PCT, ADAPT_DIV and the time constants are ratios or times and stay as they are, and the ×256 fixed-point math still fits in long (4095 x 256 = 1,048,320). The diff below shows exactly what differs from a plain AVR sketch; it is already in the sketch above. On RP2040 the serial tuning output (pk, th, nz) is in 12-bit counts, about 4 times the AVR numbers for the same hit.
+// RP2040 (arduino-pico): 12-bit ADC (0-4095), so the 0-1023 constants are scaled by 4 (AVR is unchanged).
+#if defined(ARDUINO_ARCH_RP2040)
+const int ADC_SCALE = 4;
+#else
+const int ADC_SCALE = 1;
+#endif
-const int           MIN_THRESHOLD = 30;
+const int           MIN_THRESHOLD = 30 * ADC_SCALE;   // 30 -> 120
-const int           NOISE_MARGIN  = 20;
+const int           NOISE_MARGIN  = 20 * ADC_SCALE;   // 20 -> 80
 void setup() {
   Keyboard.begin();
+#if defined(ARDUINO_ARCH_RP2040)
+  analogReadResolution(12);   // on RP2040, use the full 12-bit ADC (the core defaults to 10-bit)
+#endif
  • ADC quality and noise: the 12-bit ADC is noisier than its bit count suggests (the datasheet gives roughly 9 effective bits, with a few codes that jump), which is fine for hit detection because the thresholds are many counts wide. The ADC conversion is much faster than on the ATmega32U4, so each pad gets many more samples in the same SCAN_US window; re-check SCAN_US, NOISE_MARGIN and the cooldown with TUNE_SERIAL instead of assuming the AVR values. On a Raspberry Pi Pico the on-board switching supply can add ripple to the ADC; if nz looks high, the Pico datasheet suggests driving GP23 high (pinMode(23, OUTPUT); digitalWrite(23, HIGH); in setup()) to force the supply into PWM mode. GP23 is used differently on other boards, so check your board's pinout first. The sketch does not do this.
  • USB report interval (1 kHz): for full-speed USB, a HID interrupt endpoint interval of 1 ms (1000 Hz) is the fastest possible. This page could not confirm the default interval of the core's keyboard descriptor, so measure it: a USB descriptor viewer (USBTreeView on Windows, lsusb -v on Linux) shows the HID endpoint's bInterval, and 1 means 1 ms. If it is larger, changing it means editing the core's or TinyUSB's HID descriptor, which is an advanced change. See also the USB report interval item below.
  • Checklist: before trusting an RP2040 box, check these in order:
    • The board has four ADC pins on pads A0-A3, or you use an external ADC or multiplexer (not a plain Pico).
    • Each channel has the 1 MΩ resistor, the 1-10 kΩ series resistor and a 3.3 V clamp (Schottky pair or 3.3 V Zener); nothing at 5 V reaches a pin.
    • Tools > USB Stack is "Pico SDK", and a pad hit types its letter in a text editor.
    • analogReadResolution(12) is called and MIN_THRESHOLD / NOISE_MARGIN are 4 times larger (both done by the sketch above).
    • With TUNE_SERIAL 1, nz is low and a light hit has pk clearly above th.
    • The HID endpoint bInterval is 1, and the test panel shows no double-trigger or auto-repeat flags.

Tuning hit feel on a DIY controller box

This section is for DIY boxes that use piezo sensors with an Arduino Pro Micro, Leonardo or RP2040-style board acting as a USB keyboard. Neither the play page nor the Z-DON game has controller sensitivity settings (the trial only has the input latency compensation below), so hit feel is tuned in the box's firmware.

  • Adaptive threshold and sensitivity: a hit counts only when the piezo reading (0-1023) departs from its idle level by more than the threshold. The threshold is no longer fixed: the firmware tracks each pad's idle level and average noise with a slow moving average (EMA), and sets threshold = average noise x multiplier + margin, with a floor. Table vibration, cable movement and temperature drift no longer need retuning. Keep your hands off the drums for the first few hundred milliseconds after power-up. The resistor across the piezo (often around 1 MΩ) and the drum head material still change sensitivity, so re-test your lightest hit after changing either.
  • Peak scan window: the first sample above the threshold is usually still on the rising edge, which makes crosstalk decisions unreliable. After the first crossing the sketch keeps sampling for about 2 ms (an analogRead on the ATmega32U4 takes about 0.1 ms, so each of the 4 pads gets 4-5 samples), takes each pad's peak, and only then decides what to send. The cost is about 2 ms of extra delay, in exchange for steadier decisions.
  • Per-pad cooldown and re-arm (debounce, anti double-trigger): a piezo rings several times after one hit, so new signals on the same pad during the cooldown are ignored; after the cooldown the signal must also fall below half the threshold before the pad is ready again, so ringing is not mistaken for a new hit. A 16th note at 300 BPM is 50 ms apart, so the default cooldown is 30 ms: one pad tops out near 33 hits per second, still above normal rolls. Alternating hands on different pads is unaffected because the cooldown is per pad. Lengthen it (but stay under 50 ms) if one hit becomes two; shorten it if fast rolls get swallowed.
  • Crosstalk between pads: hitting one pad shakes its neighbors. Inside the scan window, any pad whose peak is below a set share (default 60%) of the strongest pad is ignored. A pad hit very recently (default within 12 ms) still counts as a candidate for the strongest, so its ringing cannot let a neighbor's crosstalk through. A real two-pad hit has similar peaks and is still sent together.
  • Key press duration: hold the key for roughly 10-20 ms, then release, so the PC reliably registers it. Do not hold it until the next hit: a late release makes consecutive hits blur together and can trigger the operating system's key auto-repeat. The hold time must be shorter than the cooldown (the sketch checks this at compile time) so the key is already up at the next hit.
  • USB report interval: the box's USB keyboard interface should poll at 1000 Hz (1 ms) for the lowest delay. The Arduino Keyboard library is usually already at 1 ms; on RP2040 with TinyUSB, check that the HID endpoint interval is 1. Confirm the actual numbers in your board's and library's documentation.
  • 32-bit arithmetic and the ×256 fixed point: the fixed-point math and the percentage comparison use long, because int is only 16 bits on the ATmega32U4 and would overflow. Keep the long casts if you edit the code. The idle level and noise averages are kept at ×256 (not ×16) on purpose: each update adds only 1/ADAPT_DIV of the difference, and integer division rounds that step down to 0. At ×16 with ADAPT_DIV 64, any difference under 4 counts never moved the average, so the noise floor was frozen at its power-up value and slow drift under 4 counts was never followed. At ×256 the dead band is only about 0.25 of a count.

Below is an example sketch (it targets Arduino Leonardo / Pro Micro and needs Keyboard.h). It is not guaranteed to work on your hardware as-is; adapt the pins, drum heads and feel to your build.

// Example sketch: Pro Micro / Leonardo (ATmega32U4), 4 piezos on A0-A3, sends D F J K.
// The values are only a starting point; tune them to your drum heads and piezos.
#include <Keyboard.h>

// Tuning aid: set to 1 to print one line per hit over Serial (115200 baud); 0 = no code at all.
#define TUNE_SERIAL 0

// RP2040 (arduino-pico): 12-bit ADC (0-4095), so the 0-1023 constants are scaled by 4 (AVR is unchanged).
#if defined(ARDUINO_ARCH_RP2040)
const int ADC_SCALE = 4;
#else
const int ADC_SCALE = 1;
#endif

const uint8_t PINS[4] = {A0, A1, A2, A3};
const char    KEYS[4] = {'d', 'f', 'j', 'k'};   // left ka, left don, right don, right ka (adjust the order to your wiring)

const int           MIN_THRESHOLD = 30 * ADC_SCALE; // floor for the threshold (counts above the idle level, 0-1023 scale)
const int           NOISE_MULT    = 3;     // threshold = average idle noise x this + NOISE_MARGIN
const int           NOISE_MARGIN  = 20 * ADC_SCALE; // extra counts added on top of the noise-based threshold
const unsigned long ADAPT_MS      = 10;    // how often idle readings feed the slow noise-floor average
const long          ADAPT_DIV     = 64;    // larger = slower, steadier noise-floor tracking
const unsigned long SCAN_US       = 2000;  // peak-scan window after the first crossing (microseconds)
const unsigned long COOLDOWN_MS   = 30;    // per-pad retrigger cooldown (keep well under 50 ms for 300 BPM 16ths)
const unsigned long HOLD_MS       = 15;    // how long the key is held before release (must be < COOLDOWN_MS)
const int           XTALK_PCT     = 60;    // ignore a pad whose peak is under this % of the strongest pad
const unsigned long XTALK_TAIL_MS = 12;    // a pad hit this recently still counts as the crosstalk source
const int           PAD_SENS_PCT[4] = {100, 100, 100, 100};  // per-pad sensitivity %, 50-200: 100 = unchanged, 200 = needs half the force (trigger threshold only; crosstalk compares raw peaks)

static_assert(HOLD_MS < COOLDOWN_MS, "HOLD_MS must be shorter than COOLDOWN_MS");

const long          FX            = 256;   // fixed-point scale of the idle level / noise averages (×256)
long          baseFx[4];    // idle level per pad, ×256 fixed point
long          noiseFx[4];   // average idle deviation per pad, ×256 fixed point
unsigned long lastHit[4], pressedAt[4], lastAdapt;
bool          down[4], armed[4];
int           raw[4];
int           peak[4];      // peak per pad inside the scan window

// Deviation from the idle level (also works if the piezo circuit is biased to mid-scale).
int readDev(int i) {
  raw[i] = analogRead(PINS[i]);
  long d = (long)raw[i] * FX - baseFx[i];      // long keeps the ×256 math safe from 16-bit overflow
  if (d < 0) d = -d;
  return (int)(d / FX);
}

int threshold(int i) {
  long t = noiseFx[i] * NOISE_MULT / FX + NOISE_MARGIN;
  int sens = PAD_SENS_PCT[i] > 0 ? PAD_SENS_PCT[i] : 100;   // a value of 0 or less would divide by zero: treat it as 100 (unchanged)
  t = t * 100 / sens;                          // sensitivity: long math, so ×100 cannot overflow 16-bit int on AVR; applied before the floor
  return (int)(t < MIN_THRESHOLD ? MIN_THRESHOLD : t);
}

#if TUNE_SERIAL
// Tuning output: H = sent, X = suppressed as crosstalk. pk = peak, th = threshold, nz = noise,
// gap = ms since this pad's previous hit, win = key of the pad that won the crosstalk comparison.
// Never blocks: skipped when the Serial buffer cannot take the whole line.
void tuneLog(char tag, int i, int win, unsigned long gap) {
  char buf[56];
  int n = snprintf(buf, sizeof buf, "%c %c pk=%d th=%d nz=%d gap=%lu win=%c\n",
                   tag, KEYS[i], peak[i], threshold(i), (int)(noiseFx[i] / FX), gap > 99999UL ? 99999UL : gap, KEYS[win]);
  if (n > 0 && Serial.availableForWrite() >= n) Serial.write((const uint8_t*)buf, n);
}
#endif

void setup() {
  Keyboard.begin();
#if defined(ARDUINO_ARCH_RP2040)
  analogReadResolution(12);                    // on RP2040, use the full 12-bit ADC (the core defaults to 10-bit)
#endif
#if TUNE_SERIAL
  Serial.begin(115200);                        // do not wait for the monitor: the drum works without one
#endif
  delay(300);                                  // let the analog front end settle; leave the drums untouched
  for (int i = 0; i < 4; i++) {
    long s = 0;
    for (int k = 0; k < 64; k++) { s += analogRead(PINS[i]); delay(1); }
    baseFx[i] = s * (FX / 64);                 // average ×256 (s / 64 * 256)
    long dsum = 0;
    for (int k = 0; k < 64; k++) { dsum += readDev(i); delay(1); }
    noiseFx[i] = dsum * (FX / 64);
    lastHit[i] = millis() - COOLDOWN_MS;
    armed[i] = true;
  }
}

void loop() {
  unsigned long now = millis();

  // Release keys when their time is up (no delay(), so scanning is never blocked)
  for (int i = 0; i < 4; i++)
    if (down[i] && now - pressedAt[i] >= HOLD_MS) { Keyboard.release(KEYS[i]); down[i] = false; }

  // Idle pass: re-arm settled pads, track the noise floor, look for a first crossing
  bool adapt = now - lastAdapt >= ADAPT_MS;
  if (adapt) lastAdapt = now;
  bool trig = false;
  for (int i = 0; i < 4; i++) {
    if (now - lastHit[i] < COOLDOWN_MS) continue;
    int d = readDev(i), thr = threshold(i);
    if (d < thr / 2) armed[i] = true;          // signal has died down: ready for the next hit
    if (armed[i] && d > thr) trig = true;
    else if (adapt && armed[i] && d < thr) {   // idle sample: update the slow averages
      baseFx[i]  += ((long)raw[i] * FX - baseFx[i]) / ADAPT_DIV;
      noiseFx[i] += ((long)d * FX - noiseFx[i]) / ADAPT_DIV;
    }
  }
  if (!trig) return;

  // Take each pad's peak inside the scan window (not just the first sample)
  for (int i = 0; i < 4; i++) peak[i] = 0;
  unsigned long t0 = micros();
  do {
    for (int i = 0; i < 4; i++) { int d = readDev(i); if (d > peak[i]) peak[i] = d; }
  } while (micros() - t0 < SCAN_US);

  now = millis();
  int best = 0, win = 0;                                // strongest pad that is ready or was hit a moment ago
  for (int i = 0; i < 4; i++)
    if ((now - lastHit[i] >= COOLDOWN_MS || now - lastHit[i] <= XTALK_TAIL_MS) && peak[i] > best) { best = peak[i]; win = i; }
  (void)win;                                   // only used by the serial tuning output; avoids an unused warning

  for (int i = 0; i < 4; i++) {
    if (!armed[i] || now - lastHit[i] < COOLDOWN_MS || peak[i] <= threshold(i)) continue;
    if ((long)peak[i] * 100 < (long)best * XTALK_PCT) {   // crosstalk: clearly weaker than the strongest pad
#if TUNE_SERIAL
      tuneLog('X', i, win, now - lastHit[i]);
#endif
      continue;
    }
#if TUNE_SERIAL
    unsigned long gap = now - lastHit[i];
#endif
    Keyboard.press(KEYS[i]);
    down[i] = true; armed[i] = false; pressedAt[i] = now; lastHit[i] = now;
#if TUNE_SERIAL
    tuneLog('H', i, win, gap);                   // after the press, so it never delays the hit
#endif
  }
}

One line per setting:

  • MIN_THRESHOLD: lowest the threshold may go, even in a very quiet setup.
  • NOISE_MULT: threshold = average noise x this + NOISE_MARGIN; raise it if you get false triggers.
  • NOISE_MARGIN: fixed margin added to the noise-based threshold; lower it if light taps are missed.
  • ADAPT_MS: how often idle readings update the idle level and noise average.
  • ADAPT_DIV: smoothing of those averages; larger tracks more slowly and ignores single hits better.
  • SCAN_US: peak-scan window after the first crossing, in microseconds; too short misses the peak, too long adds delay.
  • COOLDOWN_MS: per-pad retrigger cooldown; lengthen it if one hit becomes two, but keep it under 50 ms for 300 BPM 16ths.
  • HOLD_MS: how long the key is held before release; must be shorter than COOLDOWN_MS (checked at compile time).
  • XTALK_PCT: a pad whose peak is under this percentage of the strongest pad counts as crosstalk; raise it if neighbors light up.
  • XTALK_TAIL_MS: a pad hit within this time still counts as a crosstalk source, so ringing cannot release a neighbor.
  • PAD_SENS_PCT: per-pad sensitivity in percent, in key order (default {100, 100, 100, 100}; keep each value between 50 and 200; 0 or a negative value is treated as 100, so a typo cannot divide by zero). 200 means the pad needs half the force: its threshold is divided by 2 (still not below MIN_THRESHOLD). It scales only the trigger threshold, so the crosstalk comparison keeps using raw peaks: a pad made more sensitive in software is still suppressed if a neighbor's raw peak is far stronger. Use it for a pad that is clearly weaker than the others (see the log analysis below).

Flashing the sketch

  1. In the Arduino IDE select your board: Leonardo or Pro Micro for an ATmega32U4 board (the wrong board sends no keys at all). For an RP2040 board install the Arduino-Pico core first (see Using an RP2040 (Raspberry Pi Pico)).
  2. Connect the board with a data USB cable (not charge-only), paste the example sketch, check the pins and settings, and upload. On an RP2040 hold BOOTSEL while plugging the board in for the first upload; later uploads reset the board automatically.
  3. Keep Keyboard.begin() in setup(). After uploading, open a text editor and hit a pad: the PC should receive its letter (D, F, J or K).
  4. To tune with numbers, set TUNE_SERIAL 1, upload again and read the output in the Serial Monitor at 115200 baud (see Reading results and tuning). Close the Serial Monitor before using the live feed. Set it back to 0 afterwards: 0 produces no tuning code at all.
  5. Then check every pad in the test panel (next section).

Verify with the test panel

Not sure where to start? Open the "DIY drum / controller test" panel on the play page and follow its "Start here" guide (5 steps: check every pad, run a test, read the advice, compare after re-flashing, optional TUNE_SERIAL log).

DIY drum test panel: the collapsed "DIY drum / controller test" panel on the play page lights up and counts each of the D, F, J, K pads, flags suspected double triggers (the same key twice within 30 ms) and key auto-repeat, and offers a tap-along test (16 taps to a 120 BPM click) that computes your typical offset (median) and can apply it to the input latency compensation below in one click.

After changing the firmware, open the collapsed "DIY drum / controller test" panel on the play page and check, in order:

  1. Double-trigger flag: hit each pad once slowly, then roll hard. If suspected double triggers (the same key twice within 30 ms) appear, lengthen COOLDOWN_MS (under 50 ms) or raise NOISE_MARGIN.
  2. Auto-repeat flag: a key flagged as auto-repeat was held too long; shorten the key press duration and make sure the firmware always sends the release.
  3. Crosstalk: hit only one pad and watch its neighbors. If they light up too, raise the crosstalk ratio or the threshold. The panel also records which pad fired first: when one pad is the main source, the advice names it (for example "fired 5 times within 15 ms after Left don F"), so you know which pair of piezos to isolate with foam.
  4. Tap-along latency: tap 16 times to the 120 BPM click and read the typical offset (median). If it is large, first look for stray delays in the firmware, then use the panel's one-click apply to carry the result into the input latency compensation.
  5. Hit log (CSV): the panel's "Download hit log (CSV)" button saves the hits of the current session (the last 2000) as a file you can open in a spreadsheet: time, pad, the interval since the previous hit on the same pad, and a flag column marking double triggers, crosstalk and auto-repeat, plus the taps of the tap-along test if you ran one. Sort by the interval column to spot double triggers, or look for rows flagged as crosstalk. It is a complement to the firmware's TUNE_SERIAL output: the CSV shows what the browser received, while TUNE_SERIAL shows the peak, threshold and noise values inside the board.
  6. Big-note simultaneous hit: in this site's web player a big note needs both sides of the same colour hit at once, and it accepts the second hit up to 35 ms after the first (the Z-DON trial on /play counts a big note on a single hit, so it has no such window). Press "Start big-note test" and hit F and J together 8 times as prompted. The panel reports the median and p90 gap between the two sides, the share of attempts within 35 ms, and how many times the second side never arrived. Never arriving points to a keyboard rollover limit or ghost blocking: switch the controller to NKRO (USB HID) mode, or move the two keys to lines that do not share a scan line. Gaps that are often over 35 ms (the web player's window) point to firmware that sends the two sides one after another: lower COOLDOWN_MS / the debounce time, shorten SCAN_US, and make sure both sides are reported in the same scan pass.
  7. Simultaneous-key (rollover) test (keyboard mode only): the big-note test only checks two keys, but many cheap keyboard-mode controllers drop keys or add ghost keys once three or four are down (a standard USB HID boot keyboard reports at most 6 keys, and the Arduino Keyboard library sends at most 6 per report). Press "Start simultaneous-key test (hit all four)" and strike D, F, J and K together with four fingers, 8 times, releasing everything between attempts; or press "Start simultaneous-key test (hold one, hit three)", which asks you to hold one of D, F, J, K (rotating) and then hit the other three together, the case where a ka's key is still down because of HOLD_MS. For each attempt the panel records which of the four keys arrived within 50 ms, the spread, and any key that is not a pad (a neighbouring key code from matrix ghosting). It then reports the share of attempts with all four keys, the pad most often missing, the most keys held at once with a rollover estimate (1KRO / 2KRO / 3KRO / at least 4 / at least 6 / NKRO; with only four pads it can only give a lower bound, so 4 and above means "enough for four pads"), and advice. A 2KRO or 3KRO result means the keyboard mode or chip cannot report that many keys: use gamepad mode, an NKRO-capable chip or firmware, or give each key its own pin or a diode. Ghost keys are a matrix-wiring problem that firmware cannot fully fix. Misses in the hold variant often come from a HOLD_MS that is too long or a release that is never sent: keep HOLD_MS at about 10–20 ms and below COOLDOWN_MS. For a gamepad or USB drum in gamepad mode every button is reported independently, so this test is not applicable (the panel says so).

Reading results and tuning

This section explains how to read what the test panel and the board tell you, and which setting to change. Change one thing at a time, re-flash and test again.

Tuning advice and firmware lines

After about 8 hits in total (5 or more on a pad to judge that pad), the panel lists per-pad advice such as a hold that is too long, double triggers, crosstalk or a pad that is much weaker than the others, each linking to the matching section here. It stays quiet when you only used touch, since the firmware settings do not apply. For help on a forum or Discord, press "Copy diagnostics": the text includes the counters, the tap-along result and this tuning advice. Under the advice the panel also shows the matching setting lines (for example const unsigned long COOLDOWN_MS = 40;) with a copy button. The sketch's TUNE_SERIAL only prints text and has no command to change values, so the panel never writes to the board over USB: copy the line, replace the line with the same name in your sketch and re-upload. Each number is one step from the example sketch's default; fine-tune it by testing. Instead of replacing lines one by one you can also press "Download the sketch with these settings (.ino)" below the advice: the panel builds one complete .ino file from the example sketch on this page with the suggested constants applied. The form lets you pick the board (AVR Leonardo / Pro Micro or RP2040; the example sketch already handles both, so this only changes the explanatory comment at the top of the file), TUNE_SERIAL 0 or 1, and the key letters of the four pads (default D F J K). A comment at the top of the file records when it was generated and which constants were changed; if a declaration in the example sketch on this page is renamed or missing, the panel refuses to produce a file rather than output a broken one, and it also refuses when HOLD_MS is not smaller than COOLDOWN_MS. Everything happens locally in your browser and nothing is uploaded; after downloading, put the file in a folder of the same name (TaikoForgeDrum), open it in the Arduino IDE and upload.

Serial tuning mode (TUNE_SERIAL)

Instead of guessing, you can make the board report every hit. Near the top of the sketch set #define TUNE_SERIAL 1, upload, then open Tools > Serial Monitor in the Arduino IDE and select 115200 baud. Each hit prints one line, for example H d pk=312 th=64 nz=8 gap=145 win=d: H means the key was sent and X means the hit was suppressed as crosstalk; the letter after it is the pad's key; pk is the peak in counts; th is the current threshold; nz is the average idle noise; gap is the milliseconds since the previous hit on that same pad (capped at 99999); win is the key of the pad that won the crosstalk comparison (the strongest ready pad). Output is only queued after the key press and is skipped when the Serial buffer is full, so it does not delay hit reporting; with the value 0 no code is built in at all. Set it back to 0 when you are done. What to look at:

  • gap of 30-50 ms on the same pad when you hit once: ringing is counted as a second hit, so lengthen COOLDOWN_MS (under 50 ms and above HOLD_MS); if gap is only a few ms, also raise NOISE_MARGIN. If fast rolls lose hits and gap is well above COOLDOWN_MS, shorten it.
  • Hits with pk just above th while idle or when you knock the table: raise NOISE_MARGIN or MIN_THRESHOLD. If your lightest hit shows pk close to th or lines do not appear at all, lower them.
  • X lines where win is a neighbor, while you only hit one pad: the crosstalk is working; if the neighbor still fires as H with a pk of 60% or more of the winner's, raise XTALK_PCT. If a real two-pad hit shows up as X, lower it.
  • A neighbor fires right after a hard hit and gap on the hit pad is small: raise XTALK_TAIL_MS.
  • Key held too long or auto-repeat: change HOLD_MS (keep it below COOLDOWN_MS); the serial lines do not show it, so confirm with the test panel above.

The same ideas appear in the test panel advice above, so the serial output tells you which number to change and the panel confirms the effect on the PC.

Analyze a pasted TUNE_SERIAL log

Instead of reading the lines by eye, hit each pad on its own at least 10 times at a normal strength (plus a few light taps), copy the Serial Monitor lines, paste them into the "TUNE_SERIAL log" box of the "DIY drum / controller test" panel and press "Analyze log". Everything runs locally in your browser; nothing is uploaded. Other text, CRLF line ends, timestamp prefixes and cut-off lines are ignored. The format has no absolute time, so the panel works from the win field instead. The table shows per pad: H and X counts, the peak pk minimum / p10 / median / p90 (p10 = the value 10% of hits fall below), the median threshold th, pk/th (headroom) and the number of suspected noise hits. The formulas, assuming the example sketch (NOISE_MULT 3, XTALK_PCT 60, and ADC_SCALE 4 when any value is above 1023):

  • Suspected noise or ghost hit: an H line with pk under 1.25 x th (barely over the threshold), or with gap under 50 ms and pk under 60% of that pad's median peak (ringing counted as a new hit).
  • Headroom: the p10 peak of the remaining real hits divided by th. Under 1.5 means the lightest hits are too close to the threshold and may be missed.
  • NOISE_MARGIN / MIN_THRESHOLD (noise): target threshold = 1.1 x the largest noise peak, but never above (p10 real peak / 1.5), so light hits keep headroom. NOISE_MARGIN = (target - NOISE_MULT x the highest nz) / ADC_SCALE, and MIN_THRESHOLD = 0.6 x target / ADC_SCALE. If noise and real hits overlap so much that no such target exists, the panel says so and gives no line: fix the piezo mounting, wiring or shielding instead.
  • NOISE_MARGIN / MIN_THRESHOLD (no noise, little headroom): target threshold = p10 real peak / 1.8, with the same two formulas.
  • XTALK_PCT: an H line whose win is another pad passed the crosstalk test although that pad was weaker. Lines printed in a row with the same win (and no pad repeated) are treated as one scan; the ratio is this pad's pk / the winner's pk. With at least 3 such lines (and you hit one pad at a time), XTALK_PCT = ceil(p90 of the ratios) + 3, at most 90, and only if it is above the current value. X lines are crosstalk that was correctly suppressed and are only counted.
  • COOLDOWN_MS: with at least 2 weak short-gap hits, COOLDOWN_MS = (the longest such gap) + 5, at most 49 (and keep it above HOLD_MS).
  • Pad imbalance: a pad whose median peak is below 70% of the median of the other pads' medians needs clearly more force (needs 3 or more pads with 5 or more hits each). Besides advice, with the standard keys D F J K the panel prints const int PAD_SENS_PCT[4] = {100, 140, 100, 100}; in key order (100 = unchanged, 50 to 200). The example sketch above already has this setting: copy the line and replace the same-named line in your sketch (a pad above 100 gets a lower threshold). Fixing the piezo contact or head tension is better than compensating in software.

A pad needs 5 H lines before it is judged. The numbers are a starting point: upload, record again and compare.

Live feed from the board (Chrome or Edge)

Above the "TUNE_SERIAL log" box in the test panel there is a "Connect board (USB serial)" button (it only appears in browsers that support Web Serial; Firefox and Safari do not, so use the paste method above there). Press it and pick the board's serial port in the browser's list; the page opens it at 115200 baud and reads each hit line as it is printed, keeps the latest 5000 lines, re-runs the analysis at most every 500 ms, and shows the H / X count for every pad plus the last line. Before you start, close the Arduino IDE Serial Monitor: only one program can open the port at a time, and while the monitor is open the page reports that it could not open the serial port. The sketch also needs TUNE_SERIAL 1 and a fresh upload, otherwise no lines appear at all. The page only reads and never writes anything to the board; data is processed locally in your browser and never uploaded. "Pause" temporarily ignores new data, "Clear" empties the log and "Disconnect" closes the port; if the USB cable is pulled out, a reading-stopped message appears, and you can plug it back in and press connect again.

Peak chart

Below the "TUNE_SERIAL log" box the panel draws one small chart per pad, showing the peak pk of that pad's last 60 hits. Solid bars are H (sent); hollow bars with a cross are X (suppressed as crosstalk); the dashed line is the threshold th and the dotted line is the noise floor nz, so you can see whether soft hits clear the threshold with room to spare and whether the threshold hugs the noise. Under the charts each pad also has a one-line text summary (H/X counts, median peak, threshold, noise) that screen readers can read. The "hit-strength consistency" in that summary is the coefficient of variation of the H peaks (standard deviation / mean, X excluded): up to 30% is steady, 30–50% shows some variation, above 50% is a wide spread. A wide spread usually means a piezo that is not firmly attached, uneven skin tension, or hitting a different spot each time; it needs at least 5 H hits to be computed. With the live feed the charts follow the data (at most 10 updates per second); with a pasted log they are a static view. If your system asks for reduced motion there is no frame-by-frame updating, only a slower redraw. Colours and sizes follow the site styles, and everything is drawn locally in your browser with nothing uploaded.

Compare with the previous run

When a tap-along, big-note or simultaneous-key test finishes, the panel saves a numbers-only summary (no hit records) in your browser and, on the next finished test, shows a before/after table: suspected double triggers, crosstalk count, big notes within the allowed gap (%), median gap between the two sides, tap-along steadiness and each pad's median tap-along offset, each marked better, worse or same. That makes the loop of changing the firmware, re-flashing and testing again easy to judge. Press "Reset diagnostics" or "Clear counts" before each round so the counts start from zero. To keep one run as a fixed reference, press "Save as baseline", or press "Set as baseline" on that row of the run history table in the next section; with no pinned baseline the previous run is used. "Clear baseline" unpins it (the runs stay). The simultaneous-key test adds two rows when it has been run: the share of attempts with all four keys, and the most keys held at once. Nothing is uploaded.

Run history (last 12 tests)

The panel keeps the numbers-only summaries of your last 12 tests (no hit records) in one compact table: each row is a test, and the columns are time, note, suspected double triggers, crosstalk, big notes within the allowed gap, median big-note gap, tap-along steadiness, the share of simultaneous-key attempts with all four keys, the most keys held at once, and the largest per-pad tap-along offset. The best value in each column is shown in bold with a "★" (only when at least two runs have a value and they are not all equal; it is a text symbol, not just a colour), and the bottom row has a small trend chart per metric that screen readers replace with the numbers from oldest to newest. Before testing, type what you changed in the note box (for example COOLDOWN 40 or "added foam"); it is attached to the next run. Tests done in the same round (between two presses of "Reset diagnostics" or "Clear counts"), such as tap-along, big-note and simultaneous-key tests, update the same row instead of using several. Every row can be deleted or set as the baseline that later before/after tables compare against; beyond 12 runs the oldest is dropped, but the baseline row is kept. The history lives only in your browser, an older single baseline is moved into it automatically, and nothing is uploaded. The full version of "Copy diagnostics" includes this table (the short version does not, and its 2000-character limit is unchanged).

Share a report to get help

When you ask for help on Discord or a forum, press "Copy diagnostics" in the panel. It copies one compact report covering every test that has produced a result in this visit; sections without data are left out. Next to the button choose Plain text or Markdown and tick Full (longer) for the long version. The short version always fits one Discord message (2000 characters at most): if there is too much, whole low-priority sections (the before/after table, peak charts, TUNE_SERIAL summary and so on) are dropped and the report says how many; the full version keeps everything. After copying, the line next to the button tells you the character count.

The report contains: browser name, major version and OS (no full user-agent string); the input mode seen (keyboard, gamepad, serial); the gamepad read interval; the sketch settings you typed into the firmware latency form (only if you changed them) and the resulting budget; per-pad hit counts, double triggers, auto-repeat and crosstalk (the full version adds the interval histogram and crosstalk pairs); the tap-along typical offset (median), steadiness, per-pad and per-source offsets and the suggested key-delay compensation; the big-note and simultaneous-key (4-key/hold-one) results; the advice items as short ids such as dbl L-ka 6/20 (the full version adds the advice text in your own language); the suggested firmware lines; the TUNE_SERIAL analysis and per-pad hit-strength consistency as summary numbers only; and the before/after table when one is showing; the full version also has the table of the last 12 runs (notes contain only text you typed yourself).

The report never includes the raw TUNE_SERIAL log you pasted or streamed, individual hit records, or any personal data. Pad names are fixed English labels (L-ka, L-don, R-don, R-ka) so helpers can read them whatever language your page uses. Everything is built in your browser and only copied to your clipboard.

Latency budget: why does my drum feel late?

The delay from a hit to a sound is the sum of several stages, and most of it is usually not in the sketch. The table lists each stage with a typical value for the example sketch on an ATmega32U4 board (Pro Micro / Leonardo) in keyboard mode, and whether the DIY drum test panel on the play page shows it.

Stage Typical In the test panel? What you can change
Piezo pulse reaches its peak about 1-3 ms (a rule of thumb, not measured here) No Nothing in software; a firm mount and foam under the piezo keep the pulse clean
Firmware: noticing the first crossing about 0.4 ms (worst 0.8 ms): one analogRead takes about 0.11 ms, so one pass over 4 pads takes about 0.45 ms Calculated ("controller box program time") Fewer pads per board, or a faster ADC such as the RP2040's (enter your read time in the panel)
Firmware: peak wait SCAN_US SCAN_US 2000 runs 5 whole passes, about 2.2 ms Calculated Lower SCAN_US (see below)
Debounce and hold (COOLDOWN_MS, HOLD_MS) 0 ms for the first hit; they only limit repeats and how long the key is held No Only if one hit becomes two or fast rolls lose hits
USB HID reporting 1 ms interval: about 0.5 ms (worst 1 ms) Calculated from the interval you enter Keep a 1 ms interval; check the descriptor's bInterval with USBView (Windows) or lsusb -v (Linux)
OS input stack Small and not separable from the stages around it Only inside the tap-along result Plug the board straight into the PC with a wired connection
Browser, keyboard mode The key event is delivered as it arrives, with no wait for a frame Only inside the tap-along result Prefer keyboard mode
Browser, gamepad mode Read once per animation frame, so up to one frame late: 16.7 ms at 60 Hz, 6.9 ms at 144 Hz Yes: the panel shows the effective read interval Use keyboard mode, or a higher display refresh rate
Audio output Wired headphones are usually small; Bluetooth is often over 100 ms Compensated automatically in the canvas player and Z-DON; tap-along already factors it out, so applying the result does not count it twice Wired headphones or speakers

Reading the numbers: with the defaults, the sketch itself adds about 2.6 ms (worst 3.0 ms) from the first threshold crossing to Keyboard.press, and the USB report interval about 0.5 ms more. A drum that feels late by tens of milliseconds is therefore almost never the sketch: look at gamepad mode, Bluetooth audio, the display and the latency compensation first. The panel's "controller box program time" form computes this from your settings (SCAN_US, the read time per channel, the USB interval), so enter your own values if you changed them. It is a calculation from the sketch's structure, not a measurement; the tap-along test measures the whole chain.

Is the peak wait too long? A piezo pulse usually reaches its peak within about 1-3 ms (a rule of thumb: check it with your own TUNE_SERIAL log), and the key is only sent once the window ends. The default SCAN_US 2000 (about 2.2 ms in practice, because the loop only checks the clock after a whole pass) is already in that range, so the defaults are fine. A window clearly longer than about 3 ms only adds delay, and the panel says so. Going shorter saves roughly one pass (about 0.45 ms) per step on an AVR board (SCAN_US 1500 runs 4 passes), but too short a window reads a weak early sample as the peak, which hurts the crosstalk comparison and the threshold margin. Lower it a little, re-run the tests above, and stop if crosstalk or missed light hits appear.

Adjusting latency

Delay in the controller or the display can make every note feel late or early. Audio output latency (for example Bluetooth headphones) is already compensated automatically by the game from the value the browser reports, so do not add it again. The trial settings have an input latency compensation box (±300 ms) for fine-tuning what remains. It shifts the chart OFFSET handed to the game for this trial only and does not change your file.

  1. Play a steady section a few times.
  2. If your hits always feel late, raise the number (+, notes move later); if they feel early, lower it (−).
  3. The change takes effect when the next play starts and is remembered in this browser. The "Reset" button returns it to 0.

Troubleshooting

Reproduce the problem in the "DIY drum / controller test" panel on the play page first, then use this table. Find your symptom below: each row goes from the likely cause to the panel tool that confirms it and to the fix. Constant names and defaults are those of the example sketch above (COOLDOWN_MS 30, HOLD_MS 15, NOISE_MARGIN 20, MIN_THRESHOLD 30, NOISE_MULT 3, SCAN_US 2000, XTALK_PCT 60, XTALK_TAIL_MS 12, PAD_SENS_PCT 100). Change one thing at a time, re-flash, and test again.

Symptom Likely cause Confirm with this panel tool Setting or hardware fix
No key is sent at all Board is not in keyboard mode (not an ATmega32U4 / RP2040 HID board); wrong board selected when uploading; the sketch never calls Keyboard.begin(); charge-only USB cable Hit any pad: no pad lights and no counter moves. Open a text editor and check whether the PC receives characters Select Leonardo or Pro Micro in the IDE and upload again; keep Keyboard.begin() in setup(); use a data cable
One pad never triggers Wiring or polarity wrong, cold solder joint; threshold too high; cracked piezo Hit that pad: it stays dark while the others work. If it still does not light after lowering the threshold, it is hardware Check that channel's signal and ground wires; lower NOISE_MARGIN and MIN_THRESHOLD; replace the piezo
Works on PC but not on a phone The phone does not accept the USB keyboard, no OTG adapter, not enough power Open the panel on the phone: lit pads mean the keyboard is accepted. If the panel shows a gamepad, gamepad mode works too Use an OTG cable or adapter; add a powered USB hub if needed; make sure the phone browser receives keys
One hit registers twice Ringing after the hit is counted as a second hit (cooldown too short), or the key is held so long that auto-repeat kicks in; the pad may also re-arm before the signal settled The pad's "suspected double trigger" flag and the <30 column of the interval table; the per-pad advice; the "auto-repeat" flag Raise COOLDOWN_MS (under 50 ms, and above HOLD_MS) or NOISE_MARGIN; if the auto-repeat flag shows, shorten HOLD_MS and make sure the release is always sent
Hitting don also triggers ka (or a neighbour pad fires) Crosstalk: vibration travels from the struck face to its neighbour through the body The crosstalk column of the interval table and the advice that names the source pad (for example "fired within 15 ms after Left don F") Raise XTALK_PCT, then XTALK_TAIL_MS if needed; separate the two piezos with foam. If you really hit both faces at once, ignore the flag
Big notes often count as small One side never arrives (keyboard rollover or ghost blocking), or the two sides are sent more than 35 ms apart (web player only; Z-DON counts one hit) "Start big-note test": the share within 35 ms, the median gap and how many times the second side never arrived Switch to NKRO (USB HID) mode or move the keys to separate scan lines; lower COOLDOWN_MS and SCAN_US; keep COOLDOWN_MS per pad; report both sides in the same scan pass
Hitting several pads at once drops keys or adds phantom keys Keyboard rollover limit (2KRO / 3KRO, or the 6-key report limit with other keys held), matrix ghosting, or HOLD_MS so long that earlier keys are still down "Start simultaneous-key test" (both variants): the share with all four keys, the pad most often missing, the most keys held at once, extra non-pad keys Use gamepad mode or an NKRO chip/firmware; give each key its own pin or a diode; keep HOLD_MS at about 10–20 ms and below COOLDOWN_MS
Feels late Mostly not the sketch (about 3 ms): gamepad mode (up to one frame), Bluetooth audio, the display, or a long SCAN_US "Start tap-along test" (typical offset (median), per-pad and per-source offsets); the "controller box program time" form; the gamepad read interval line; a steady offset can be applied in one click, a wildly varying one points to the firmware Use keyboard mode and wired audio; apply the tap-along result with one click; shorten SCAN_US only if the form says the window is too long (too short misses the peak); check the 1 ms USB interval
Soft hits are missed Threshold too high for the lightest hits, a weak pad, or a poorly mounted piezo The per-pad advice ("only N hits, far fewer than the other pads"); in the log analyzer, "the lightest real hit is only x times the threshold" Lower NOISE_MARGIN and MIN_THRESHOLD; raise that pad's PAD_SENS_PCT entry (100 = unchanged); re-seat the piezo against the drum head and check its wiring
Random hits when not touching Threshold below the noise, a missing 1 MΩ resistor across the piezo, long unshielded wires, vibration from the table With hands off the counters must not move; the log analyzer's "suspected noise" column and its ghost-hit advice; if they rise only when you knock the table or touch the cable, it is vibration or wiring Raise NOISE_MARGIN, MIN_THRESHOLD and, if needed, NOISE_MULT; add a 1 MΩ resistor across every piezo; shorten or shield the wires. If the analyzer says raising the threshold would also kill your lightest hits, fix the mounting and wiring instead
Works in the test panel but not in the game The game does not have keyboard focus; or in gamepad mode the game uses its default mapping rather than your buttons; or auto-play is on If the panel lights up, the box and the browser receive your hits, so the problem is between the page and the game; the "Copy diagnostics" text shows the input source Click the game once (or follow its "click the game to continue" hint); turn off "Auto-play" and tick "Use the drum buttons I set in the test panel"; or switch the box to keyboard mode. No firmware setting is involved
Gamepad buttons are not recognised The browser has not detected the pad yet, the button is not bound to a pad, or several pads are connected Press the button: the panel shows its number when it is unbound; the read interval line appears once a pad is seen Press any button once so the browser detects the pad; in the player's "Input settings" press Bind and press the button for each pad; pick one pad if several are connected; or use keyboard mode. No firmware setting is involved

Gamepad and USB drum mode

  • Standard gamepad: the game reads it natively with its default mapping: the left and right triggers = ka, clicking the left and right sticks = don. To use your own buttons instead, set the drum buttons in the "DIY drum / controller test" panel above, then turn off "Auto-play" and tick "Use the drum buttons I set in the test panel"; if you get double hits, untick it. Press any button once so the browser detects the pad. The "DIY drum / controller test" panel on the play page also counts gamepad buttons on the same four pads (standard layout), so you can check that a USB drum is detected.
  • USB drum / gamepad mode (analog axes, triggers): many DIY and commercial drums appear as USB gamepads. In the player's Input settings press Bind and, when prompted, press the button (or pull the trigger, or move the axis) for Left Don, Right Don, Left Ka and Right Ka. Any button or analog axis can be bound and is saved in your browser; with several gamepads you can pick one. Analog axes and triggers use hysteresis: a press needs to exceed the threshold and it only releases once it falls below 60% of it (0.3 for triggers), so jitter around the threshold does not fire repeatedly. The test panel and the player share these bindings; if you press an unbound button, the panel tells you its button number. Unplugging and re-plugging a pad is treated as a new device, so a held button is not counted as a hit.
  • Measurement floor for gamepads: the browser reads a gamepad once per frame (about 16.7 ms), so hit times are quantized up to one frame late. The test panel shows the effective read interval and the state update interval the pad reports, and includes them in "Copy diagnostics"; latency or interval differences smaller than the read interval cannot be measured, and that is not a fault in your box.

Remembered preferences

Auto-play, course, mode and the fullscreen choice are remembered in this browser. To clear them, press "Reset preferences" in the settings (the latency box has its own Reset button).

Glossary

This page and the test panel on the play page use one set of words. The left column is the term used in the panel and here, the middle column is the plain explanation, and the right column lists other names you may meet elsewhere or the matching name in the code.

Term Plain meaning Other names / matching name
Controller box The drum controller you built: piezos, a board and a USB cable controller, DIY drum
Pad One of the four hit surfaces: left ka D, left don F, right don J, right ka K drum face
Example sketch The Arduino program you upload to the board firmware, draft
Setting A number near the top of the sketch that you can change, one at a time constant, for example COOLDOWN_MS
Upload Sending the edited program to the board flash, burn
Threshold How hard you must hit for it to count; weaker signals are treated as no hit th, NOISE_MARGIN, MIN_THRESHOLD
Hit strength How big the signal of one hit is peak, pk
Noise The background reading when nobody is hitting nz
Cooldown The time after a hit during which the same pad ignores new triggers debounce, COOLDOWN_MS
Hold time How long the key stays pressed before it is released HOLD_MS
Double trigger One hit counted as two double hit, COOLDOWN_MS
Crosstalk Hitting one pad makes another pad fire too cross-talk, XTALK_PCT
Auto-repeat A key held so long that the computer keeps receiving the same letter HOLD_MS
Simultaneous keys (rollover) How many keys a keyboard can report at once; beyond that keys drop 2KRO, 6KRO, NKRO (all keys independent)
Ghost key A key that was not pressed is reported as pressed, caused by matrix wiring ghosting
Typical offset (median) How early or late your taps are on typical; positive means late median offset
Steadiness How much your tap timing wobbles; smaller is steadier spread
Hit-strength consistency How much the strength varies from hit to hit; smaller means more even consistency, coefficient of variation
Baseline The run you compare later tests against reference run
Gamepad A USB gamepad, or a USB drum in gamepad mode; each button reports on its own joystick, controller
Read interval How often the browser reads the gamepad state poll interval
TUNE_SERIAL log The per-hit numbers the sketch prints, used to fine-tune settings serial log, TUNE_SERIAL
Key latency compensation The number in the play settings that cancels a constant early or late feel play latency offset

Related: Play TJA charts in your browser

If hits are not registering or timing feels off, check the FAQ as well.