Skip to content

Instantly share code, notes, and snippets.

@jrmedd
Last active December 14, 2015 19:09
Show Gist options
  • Save jrmedd/5134333 to your computer and use it in GitHub Desktop.
Save jrmedd/5134333 to your computer and use it in GitHub Desktop.
#include "DigiKeyboard.h"
int tilt = 0;
int leftUp = 1;
int rightDown = 2;
void setup() {
pinMode(tilt, INPUT);
pinMode(leftUp, INPUT);
pinMode(rightDown, INPUT);
}
void loop() {
DigiKeyboard.update();
int tiltState = digitalRead(tilt);
int leftUpState = digitalRead(leftUp);
int rightDownState = digitalRead(rightDown);
if (tiltState == HIGH) {
if (leftUpState == HIGH) {
DigiKeyboard.sendKeyStroke(KEY_W);
}
if (rightDownState == HIGH) {
DigiKeyboard.sendKeyStroke(KEY_S);
}
}
else {
if (leftUpState == HIGH) {
DigiKeyboard.sendKeyStroke(KEY_A);
}
if (rightDownState == HIGH) {
DigiKeyboard.sendKeyStroke(KEY_D);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment