Skip to content

Instantly share code, notes, and snippets.

@mrchimp
Created April 1, 2018 00:31
Show Gist options
  • Select an option

  • Save mrchimp/ba426462697ce2645bc77d52e460f045 to your computer and use it in GitHub Desktop.

Select an option

Save mrchimp/ba426462697ce2645bc77d52e460f045 to your computer and use it in GitHub Desktop.
Arduino simple keypress
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