Last active
October 27, 2018 20:22
-
-
Save EnotionZ/e56bb45b10365d18c9e7b4b337f5a27a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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