I had a question regarding how to hold down keys in Ardunio, here is my code so far:
#include <Keyboard.h>
#define LJX_PIN A0
#define LJY_PIN A1
int LJX_VAL;
int LJY_VAL;
void setup() {
// STARTS
Serial.begin(9600);
Keyboard.begin();
}
void loop() {
LJX_VAL = analogRead(LJX_PIN);
LJY_VAL = analogRead(LJY_PIN);
// HOLDS DOWN NO REPRECUSION
if (LJX_VAL >= 1000){
Keyboard.write('w');
}
if (LJX_VAL <= 100){
Keyboard.write('s');
}
if (LJY_VAL >= 1000){
Keyboard.write('d');
}
if (LJY_VAL <= 100){
Keyboard.write('a');
}
}
I have a joystick with the hookups displayed in the code. When holding left the keyboard repeatedly presses 'a' instead of just holding it. Also I know that there is no release on the keyboard, that is just because I was testing multiple things. I was wondering if there is any way to adjust my code to make the 'a' key get held down or if there is another library that can do the same thing?