/*
|
|
Pedal to Key takes in 2 (drum pedal) inputs and turns
|
|
them into two separate key presses
|
|
|
|
Created in 2023
|
|
by Brett Bender for Will Dean of UW-Stout PONG
|
|
|
|
This code is licensed under the MIT License
|
|
*/
|
|
|
|
#ifndef USER_USB_RAM
|
|
#error "This program needs to be compiled with a USER USB setting"
|
|
#endif
|
|
|
|
#include "src/userUsbHidKeyboard/USBHIDKeyboard.h"
|
|
|
|
#define BUTTON1_PIN 33
|
|
#define BUTTON1_CHAR 'd'
|
|
|
|
#define BUTTON2_PIN 32
|
|
#define BUTTON2_CHAR 'k'
|
|
|
|
bool button1PressPrev = false;
|
|
bool button2PressPrev = false;
|
|
|
|
void setup() {
|
|
USBInit();
|
|
pinMode(BUTTON1_PIN, INPUT_PULLUP);
|
|
pinMode(BUTTON2_PIN, INPUT_PULLUP);
|
|
}
|
|
|
|
void loop() {
|
|
//button 1 is mapped to letter 'd'
|
|
bool button1Press = !digitalRead(BUTTON1_PIN);
|
|
if (button1PressPrev != button1Press) {
|
|
button1PressPrev = button1Press;
|
|
if (button1Press) {
|
|
Keyboard_press(BUTTON1_CHAR);
|
|
} else {
|
|
Keyboard_release(BUTTON1_CHAR);
|
|
}
|
|
}
|
|
|
|
//button 2 is mapped to letter 'd'
|
|
bool button2Press = !digitalRead(BUTTON2_PIN);
|
|
if (button2PressPrev != button2Press) {
|
|
button2PressPrev = button2Press;
|
|
if (button2Press) {
|
|
Keyboard_press(BUTTON2_CHAR);
|
|
} else {
|
|
Keyboard_release(BUTTON2_CHAR);
|
|
}
|
|
}
|
|
|
|
delay(50); //naive debouncing
|
|
}
|