Skip to content

Instantly share code, notes, and snippets.

@cbmainz
Last active December 11, 2017 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbmainz/7c77b41c6888747cf5f2ecf9ab8ac4d8 to your computer and use it in GitHub Desktop.
Save cbmainz/7c77b41c6888747cf5f2ecf9ab8ac4d8 to your computer and use it in GitHub Desktop.
#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