#define motor1 13 #define motor2 12 #define EnA 11 #define JoyX A0 #define JoyY A1 //boolean sentido = true; int espera = 500; void setup() { pinMode(motor1, OUTPUT); pinMode(motor2, OUTPUT); pinMode(EnA, OUTPUT); } //Valor JoyX a la Izq de 524 a 0 //Valor JyY a la Der de 526 a 1023 void giro() { int ejeX = analogRead(JoyX); if(ejeX < 525) { digitalWrite(motor2, LOW); digitalWrite(motor1, HIGH); analogWrite(EnA,map(ejeX,524,0,0,255)); } else if(ejeX > 525) { digitalWrite(motor1, LOW); digitalWrite(motor2, HIGH); analogWrite(EnA,map(ejeX,526,1023,0,255)); } else { detener(); } } void detener() { digitalWrite(motor1, LOW); digitalWrite(motor2, LOW); } void loop() { giro(); }