Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created February 15, 2020 04:34
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
// 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