This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Leer del joystick | |
int obtenerDireccion() { | |
int valorX = analogRead(pinX), | |
valorY = analogRead(pinY); | |
if (valorX > 1000) { | |
return DIRECCION_ARRIBA; | |
} else if (valorX < 200) { | |
return DIRECCION_ABAJO; | |
} | |
if (valorY > 1000) { | |
return DIRECCION_DERECHA; | |
} else if (valorY < 200) { | |
return DIRECCION_IZQUIERDA; | |
} | |
// Regresamos algo inválido, pues no se cambió, | |
// y dependemos de la función cambiarDireccion | |
return -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment