I am creating an 11 button gamepad with a arduino leonardo for a game called clone hero which is like guitar hero. I have the gamepad working with a code i put together from examples ive found in videos. i can play the game. the problem is when its time for a chord or a long held chord, the inputs dont happen. it will press whatever button i pressed first and only for a brief second. attached is the code
#include <Keyboard.h>
int pinA = 2;
int pinB = 3;
int pinC = 4;
int pinD = 5;
int pinE = 6;
int pinF = 7;
int pinG = 8;
int pinH = 9;
int pinI = 10;
int pinJ = 11;
int pinK = 12;
void setup() {
pinMode(pinA, INPUT_PULLUP);
pinMode(pinB, INPUT_PULLUP);
pinMode(pinC, INPUT_PULLUP);
pinMode(pinD, INPUT_PULLUP);
pinMode(pinE, INPUT_PULLUP);
pinMode(pinF, INPUT_PULLUP);
pinMode(pinG, INPUT_PULLUP);
pinMode(pinH, INPUT_PULLUP);
pinMode(pinI, INPUT_PULLUP);
pinMode(pinJ, INPUT_PULLUP);
pinMode(pinK, INPUT_PULLUP);
}
void loop() {
if (digitalRead(pinA) == LOW)
{
Keyboard.write('');
delay(50);
}
if (digitalRead(pinB) == LOW)
{
Keyboard.write('A');
delay(50);
}
if (digitalRead(pinC) == LOW)
{
Keyboard.write('S');
delay(50);
}
if (digitalRead(pinD) == LOW)
{
Keyboard.write('J');
delay(50);
}
if (digitalRead(pinE) == LOW)
{
Keyboard.write('K');
delay(50);
}
if (digitalRead(pinF) == LOW)
{
Keyboard.write('L');
delay(50);
}
if (digitalRead(pinG) == LOW)
{
Keyboard.write(' ');
delay(50);
}
if (digitalRead(pinH) == LOW)
{
Keyboard.write('Q');
delay(50);
}
if (digitalRead(pinI) == LOW)
{
Keyboard.write('P');
delay(50);
}
if (digitalRead(pinJ) == LOW)
{
Keyboard.write(';');
delay(50);
}
if (digitalRead(pinK) == LOW)
{
Keyboard.write('H');
delay(50);
}