This project attempts to make a pedal board with 4 footswitches that perform macros that can be used by LiveSplit to perform actions. The combination of buttons used is slightly irrelevant, as LiveSplit can be configured to use any key, or combination of keys, for any specific function.
I have no coding background whatsoever, and I am attempting to learn this as I go. The following is the code I have written for the project. I have written this code by adapting code used in Examples provided by the ArduinoIDE.
#include "keyboard.h"
void setup() {
// put your setup code here, to run once:
pinMode(3, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
Keyboard.begin();
}
void loop() {
// put your main code here, to run repeatedly:
while (digitalRead(3)==HIGH) {
delay(500);
}
if (digitalRead(3)==LOW){
Keyboard.press(KEY_RIGHT_CTRL);
Keyboard.press(KEY_RIGHT_SHIFT);
Keyboard.press(89);
delay(100);
Keyboard.releaseAll();
}
if (digitalRead(5)==LOW){
Keyboard.press(KEY_RIGHT_CTRL);
Keyboard.press(KEY_RIGHT_SHIFT);
Keyboard.press(90);
delay(100);
Keyboard.releaseAll();
}
while (digitalRead(7)==HIGH) {
delay(500);
}
if (digitalRead(7)==LOW){
Keyboard.press(KEY_RIGHT_CTRL);
Keyboard.press(KEY_RIGHT_SHIFT);
Keyboard.press(91);
delay(100);
Keyboard.releaseAll();
}
while (digitalRead(9)==HIGH) {
delay(500);
}
if (digitalRead(9)==LOW){
Keyboard.press(KEY_RIGHT_CTRL);
Keyboard.press(KEY_RIGHT_SHIFT);
Keyboard.press(92);
delay(100);
Keyboard.releaseAll();
}
}
The issue that I'm running into here is that each macro works, but only if I press them in the order that they are written in the code; ie, press the button on pin 3, then pin 5, then pin 7, etc. I need any of these macros to be executed in any order.
I would greatly appreciate it if someone could point out what I am missing here, or even tell me if I've done it all wrong, and suggest another function I could use instead.
Thanks,
DarkXoa
EDIT: Forgot to mention that I am using an Arduiuno Micro with AtMega32U4.