Created
June 20, 2015 20:02
-
-
Save UlisesGascon/7f6d96fd9a2899195237 to your computer and use it in GitHub Desktop.
pptls - Arduino Choice
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
// Definimos la eleccion del jugador y Arduino a cero. | |
String eleccionArduino = "vacio"; | |
// ==== EMPIEZA EL LOOP() ==== | |
void loop (){ | |
// === ELECCIÓN ARDUINO === | |
// la elección de Arduino es un numero al azar entre 1 y 5. | |
int eleccionRandom = random(1, 6); | |
// convertir ese numero en la cadena de texto correpondiente | |
// continuamente hasta que el jugador humano haga su elección. | |
if(eleccionRandom == 1){ | |
// Arduino elige piedra | |
eleccionArduino = "piedra"; | |
}else if( eleccionRandom == 2 ){ | |
// Arduino elige papel | |
eleccionArduino = "papel"; | |
}else if( eleccionRandom == 3 ){ | |
// Arduino elige tijeras | |
eleccionArduino = "tijeras"; | |
}else if( eleccionRandom == 4 ){ | |
// Arduino elige lagarto | |
eleccionArduino = "lagarto"; | |
}else if( eleccionRandom == 5 ){ | |
// Arduino elige Spock | |
eleccionArduino = "spock"; | |
} else{ | |
// Si el valor se sale de lo esperado... avisamos al usuario. | |
Serial.print("Arduino es un tramposo! Arregla su codigo"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment