Good day to you all.
So, i wanted to find a cheaper alternative to my Teensy LC as a USB HID for wiring buttons to it and acting as a gamepad/keyboard for emulators.
I bought an Arduino Leonardo, to test if it even works, and wanted to use the same code, but of course, it did not work.
So i used a different code/sketch:
void setup()
{
pinMode(5,INPUT);
digitalWrite(5,HIGH);
Keyboard.begin();
while(digitalRead(5))
{
}
//Joystick and button connections
pinMode(2, INPUT_PULLUP); //rechts oder D
pinMode(3, INPUT_PULLUP); //links oder A
}
void loop() {
// Check the switches:
int buttonState2 = digitalRead(2);
int buttonState3 = digitalRead(3);
// rechts oder D
if (buttonState2 == LOW) {
Keyboard.press('D');
}
else {
Keyboard.release('D');
}
// links oder A
if (buttonState3 == LOW) {
Keyboard.press('A');
}
else{
Keyboard.release('A');
}
}
This is just a test code to get it all started, i will add more buttons after it works.
Now my problem.
I read that other suers had one big issue. The Leonardo Clone does not have a button, so you can not make him go into programming mode. Which means, if they programmed it to act as a USB HID device, it won't let them reprogram it, as it is sending inputs constantly.
At least, that is what i understood was happening.
Now, they wrote about a jumper that would be connected to some pins. If this jumper is set, it would let the module go into USB HID mode, if you disconnect it, you can program it again, because it would stop acting as one.
As i am completely new to all this, i had problems finding a way to tell my board to use such a switch, i also failed in contacting those users and asking them to tell me how they did this.
Is someone here kind enough to explain to me how i could manage to do this (Hardware and Software)?
That would be great and i would be really grateful.
Thank you kindly and regards
Mitch
p.s. my old code included a "bounce.h", is this necessary?