Last active
December 11, 2017 14:27
-
-
Save cbmainz/7c77b41c6888747cf5f2ecf9ab8ac4d8 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> | |
int analogValue0 = 0; | |
int analogValue1 = 0; | |
int analogValue2 = 0; | |
int threshold = 800; | |
int wait = 200; | |
void setup() { | |
Serial.begin(9600); | |
Keyboard.begin(); | |
} | |
void loop() { | |
analogValue0 = analogRead(A0); | |
analogValue1 = analogRead(A1); | |
analogValue2 = analogRead(A2); | |
if (analogRead(A0) > threshold) | |
{ | |
Keyboard.press('w'); | |
Serial.println(analogValue2); | |
delay(wait); | |
Keyboard.release('w'); | |
} | |
else if (analogRead(A1) < threshold) | |
{ | |
Keyboard.press('a'); | |
Serial.println(analogValue1); | |
delay(wait); | |
Keyboard.release('a'); | |
} | |
else if (analogRead(A2) < threshold) | |
{ | |
Keyboard.press('s'); | |
Serial.println(analogValue2); | |
delay(wait); | |
Keyboard.release('s'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment