Skip to content

Instantly share code, notes, and snippets.

@EnotionZ
Last active October 27, 2018 20:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EnotionZ/e56bb45b10365d18c9e7b4b337f5a27a to your computer and use it in GitHub Desktop.
Save EnotionZ/e56bb45b10365d18c9e7b4b337f5a27a to your computer and use it in GitHub Desktop.
#include <Keyboard.h>
const int PEDAL_PIN = 2;
int pedalVal = LOW;
char keyToSend = 'm';
void setup() {
Serial.begin(9600);
pinMode(PEDAL_PIN, INPUT);
Keyboard.begin();
if(digitalRead(PEDAL_PIN) == HIGH) {
keyToSend = KEY_ESC;
}
}
void loop() {
int newPedalVal = digitalRead(PEDAL_PIN);
if(newPedalVal != pedalVal) {
pedalVal = newPedalVal;
if(pedalVal == HIGH) {
Keyboard.press(keyToSend);
} else {
Keyboard.releaseAll();
}
}
delay(50);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment