Troubleshooting DIY DDR Pad

Hello All,
I hope this is the right place for my issues. This is my first project with Arduinos so I am woefully inexperienced with it.

Hardware: Arduino Leonardo

Code: (from this forum post: Debouncing dance pad keyboard input device - Programming Questions - Arduino Forum) Loaded with IDE v1.8.13

#include "Button.h"
#include <Keyboard.h>

Button buttons[4] = { 4, 5, 6, 7 };
const char keys[4] = { 'i', 'j', 'k', 'l' };

void setup() {
  Keyboard.begin();
}

void loop() {
  for (uint8_t i = 0; i < 4; i++) {
    Button::State state = buttons[i].getState();
    if (state == Button::Falling)
      Keyboard.press(keys[i]);
    else if (state == Button::Rising)
      Keyboard.release(keys[i]);
  }
}

Schematics:

The pads have aluminum foil on the bottom side to bridge the comb-shaped contacts when i step on the pad, sending keystrokes for the duration that I step on it. A side of each of the four pads is hooked up to their own pin, and the other sides are connected together to ground.

The Problem:
Whenever there are a lot of inputs in quick succession such as in the attached image of the audio-sync level for the game,

The arduino seems to lock up and not take any inputs. I noted that during normal operation, the TX LED lights up whenever I step on a pad and turns off when I lift my feet, but when it locks up, the TX LED is stuck on. Even unplugging the wires does not turn it off so I think there is something wrong with the board itself. I have tried different cables and different computers, yet the problem persists.

Any help would be greatly appreciated and I can provide more information if needed.

There's a limit to the number of keys that can be pressed at once in both the library and the OS of the computer at the receiving end. Look for a library that can handle NKRO, NicoHood's HID library is good.

There's another potential problem. Your code takes some (admittedly small) time to go around the loop four times before coming back to update each pin. What happens if the pin is no longer rising by the time the loop comes around to look at it? You may need to save the state of each pin and only send the press or release if it's state has changed.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.