Você está na página 1de 2

#include <Keyboard.

h> fntL = false;


}
boolean fntL = false;
boolean fntR = false; if(analogRead(3) - baseValFR > 10){
boolean bckL = false; fntR = true;
boolean bckR = false; }
else if(analogRead(3) - baseValFR < -10){
int baseValFL = 0; fntR = false;
int baseValFR = 0; }
int baseValBL = 0;
int baseValBR = 0; if(analogRead(4) - baseValBL > 10){
bckL = true;
void setup() { }
Keyboard.begin(); else if(analogRead(4) - baseValBL < -10){
Serial.begin(9600); bckL = false;
}
for(int x = 2; x < 6; x++){
pinMode(x, INPUT); if(analogRead(5) - baseValBR > 10){
} bckR = true;
while(analogRead(2) - baseValFL > 10){ }
baseValFL = analogRead(2); else if(analogRead(5) - baseValBR < -10){
delay(250); bckR = false;
} }
while(analogRead(3) - baseValFR > 10){
baseValFR = analogRead(3); /*/Doing various things depending on what
delay(250); sensors have been activated/*/
} if(fntL && fntR){
while(analogRead(4) - baseValBL > 10){ Serial.println("FRONT");
baseValBL = analogRead(4); Keyboard.press('W');
delay(250); }
} else{
while(analogRead(5) - baseValBR > 10){ Keyboard.release('W');
baseValBR = analogRead(5); }
delay(250); if(fntL && bckL){
} Serial.println("LEFT");
} Keyboard.press('A');
}
void loop() { else{
/*/Setting the Variables to if the Sensors Keyboard.release('A');
have been activated/ deactivated/*/ }
if(analogRead(2) - baseValFL > 10){ if(bckL && bckR){
fntL = true; Serial.println("BACK");
} Keyboard.press('S');
else if(analogRead(2) - baseValFL < -10){ }
else{
Keyboard.release('S');
}
if(fntR && bckR){
Serial.println("RIGHT");
Keyboard.press('D');
}
else{
Keyboard.release('D');
}
}

Você também pode gostar