Created
April 1, 2018 00:31
-
-
Save mrchimp/ba426462697ce2645bc77d52e460f045 to your computer and use it in GitHub Desktop.
Arduino simple keypress
This file contains hidden or 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
| const int PIN_INT_LED = LED_BUILTIN; | |
| const int PIN_BTN_1 = 6; | |
| int pedal = 0; | |
| int pedal_previous = 0; | |
| void setup() { | |
| pinMode(PIN_BTN_1, INPUT_PULLUP); | |
| pinMode(PIN_INT_LED, OUTPUT); | |
| } | |
| void loop() { | |
| pedal = digitalRead(PIN_BTN_1); | |
| if (pedal == 1) { | |
| digitalWrite(PIN_INT_LED, HIGH); | |
| } else { | |
| digitalWrite(PIN_INT_LED, LOW); | |
| } | |
| if (pedal == 1 && pedal_previous == 0) { | |
| Keyboard.release('z'); | |
| pedal_previous = pedal; | |
| delay(1); | |
| } else if (pedal == 0 && pedal_previous == 1) { | |
| Keyboard.press('z'); | |
| pedal_previous = pedal; | |
| delay(1); | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment