diff --git a/server/commande_telephone.ino b/server/commande_telephone.ino index 059b78f..cbb65aa 100644 --- a/server/commande_telephone.ino +++ b/server/commande_telephone.ino @@ -54,33 +54,35 @@ void setup() // Code exécuté en boucle jusqu'à l'extinction du robot void loop() { - if (commandRunning) + // Ne rien faire si aucune commande en cours + if (!commandRunning) + return; + + // Arrêter le robot si une commande est interrompue + if (stopCommand) { - if (!stopCommand) - { - chooseCommand(); // Appeler la fonction "chooseCommand()" - if (globalValue > 0) - { // S'il reste des pas à effectuer alors on l'affiche et on enlève un pas - Serial.print(globalCommand); - Serial.print(": "); - Serial.println(globalValue); - globalValue--; - } - else - { // Sinon on stoppe les moteurs - Serial.println("stop"); - commandRunning = false; - stopCommand = false; - stopMotors(); - } - } - else - { - Serial.println("stop"); - commandRunning = false; - stopCommand = false; - stopMotors(); - } + Serial.println("stop"); + commandRunning = false; + stopCommand = false; + stopMotors(); + return; + } + + // Sinon executer la commande en cours + chooseCommand(); // Appeler la fonction "chooseCommand()" + if (globalValue > 0) + { // S'il reste des pas à effectuer alors on l'affiche et on enlève un pas + Serial.print(globalCommand); + Serial.print(": "); + Serial.println(globalValue); + globalValue--; + } + else + { // Sinon on stoppe les moteurs + Serial.println("stop"); + commandRunning = false; + stopCommand = false; + stopMotors(); } }