const int joystickUP = 25; //Palanca derecha
const int joystickLR = 26; //Palanca izquierda
int centro = 2048;
int LedUP = 34;
int LedR = 35;
int LedDown = 32;
int LedL = 33;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(LedUP, OUTPUT);
pinMode(LedR, OUTPUT);
pinMode(LedDown, OUTPUT);
pinMode(LedL, OUTPUT);
}
void loop() {
Serial.print(analogRead(joystickUP));
Serial.print(" ");
Serial.println(analogRead((joystickLR)));
delay(10); // this speeds up the simulation
if (analogRead(joystickUP) > (centro + 100) && analogRead((joystickLR)) < (centro + 100) && analogRead((joystickLR)) > (centro - 100)) {
Serial.println("Arriba");
//digitalWrite(LedUP, LOW);
} if (analogRead(joystickUP) > (centro + 100) && analogRead((joystickLR)) < (centro - 100)) {
Serial.println("UP R");
} if (analogRead((joystickLR)) < (centro - 100) && analogRead(joystickUP) < (centro + 100) && analogRead(joystickUP) > (centro - 100)) {
Serial.println("Right");
} if (analogRead((joystickLR)) < (centro - 100) && analogRead(joystickUP) < (centro - 100)) {
Serial.println("Down R");
} if (analogRead(joystickUP) < (centro - 100) && analogRead((joystickLR)) < (centro + 100) && analogRead((joystickLR)) > (centro - 100)) {
Serial.println("Down");
}
}