Created
January 4, 2018 19:28
-
-
Save BarrYPL/d565744816940fd69d790d9b7f9423c3 to your computer and use it in GitHub Desktop.
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
#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