Skip to content

Instantly share code, notes, and snippets.

@BarrYPL
Created January 4, 2018 19:28
Show Gist options
  • Save BarrYPL/d565744816940fd69d790d9b7f9423c3 to your computer and use it in GitHub Desktop.
Save BarrYPL/d565744816940fd69d790d9b7f9423c3 to your computer and use it in GitHub Desktop.
#include <Keyboard.h>
int ledPin1 = 4;
int inPin1 = 8;
int ledPin2 = 6;
int inPin2 = 9;
int val = 0;
void setup() {
pinMode(ledPin1, OUTPUT);
pinMode(inPin1, INPUT);
pinMode(ledPin2, OUTPUT);
pinMode(inPin2, INPUT);
Keyboard.begin();
}
void loop(){
val = digitalRead(inPin1);
if (val == HIGH) {
digitalWrite(ledPin1, HIGH);
Keyboard.press('z');
} else {
digitalWrite(ledPin1, LOW);
Keyboard.release('z');
}
val = digitalRead(inPin2);
if (val == HIGH) {
digitalWrite(ledPin2, HIGH);
Keyboard.press('x');
} else {
digitalWrite(ledPin2, LOW);
Keyboard.release('x');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment