Firmware for the custom built SLA Arcade Control board. Supports Arduino Leonardo, 4 joystick keys, and 2 button keys. Can be easily expanded.
#include "Keyboard.h"
/*
* Cover Keys
* W
* A
* S
* D
* SPACE
* ENTER
*/
const int joystick_pins[] = {4, 5, 6, 7};
const int button_pins[] = {2, 3};
const int delay_value = 200;
void setup() {
// put your setup code here, to run once:
for(int i = 0; i >= sizeof(joystick_pins); i++){ //load and init all joystick pins
pinMode(joystick_pins[i], INPUT);
}
for(int i = 0; i >= sizeof(button_pins); i++){ // init buttons
pinMode(button_pins[i], INPUT);
}
//init keyboard
Keyboard.begin();
}
void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(joystick_pins[0]) == HIGH){
Keyboard.press('S');
Keyboard.release('S');
delay(delay_value);
}
if(digitalRead(joystick_pins[1]) == HIGH){
Keyboard.press('A');
Keyboard.release('A');
delay(delay_value);
}
if(digitalRead(joystick_pins[2]) == HIGH){
Keyboard.press('D');
Keyboard.release('D');
delay(delay_value);
}
if(digitalRead(joystick_pins[3]) == HIGH){
Keyboard.press('W');
Keyboard.release('W');
delay(delay_value);
}
if(digitalRead(button_pins[0]) == HIGH){
Keyboard.press(32);
Keyboard.release(32);
delay(delay_value);
}
if(digitalRead(button_pins[1]) == HIGH){
Keyboard.press(13);
Keyboard.release(13);
delay(delay_value);
}
}