| Ligne 60 : |
Ligne 60 : |
| | // Par exemple: l1,HIGH ou l1,LOW pour allumer ou éteindre la LED1 | | // Par exemple: l1,HIGH ou l1,LOW pour allumer ou éteindre la LED1 |
| | // l2,HIGH or l2,LOW pour allumer ou éteindre la LED2 | | // l2,HIGH or l2,LOW pour allumer ou éteindre la LED2 |
| − | | + | // |
| | int ledControl(String command) | | int ledControl(String command) |
| | { | | { |
| | int state = 0; | | int state = 0; |
| − | //find out the pin number and convert the ascii to integer | + | // Trouver le numéro de broche dans la commande ET convertir |
| | + | // la valeur du caractere ASCII en valeur entière (en integer) |
| | int pinNumber = (command.charAt(1) - '0') - 1; | | int pinNumber = (command.charAt(1) - '0') - 1; |
| − | //Sanity check to see if the pin numbers are within limits | + | |
| | + | // Vérifier que la valeur de la broche est bien dans |
| | + | // les limites acceptables SINON on quitte de la fonction ledControl |
| | if (pinNumber < 0 || pinNumber > 1) return -1; | | if (pinNumber < 0 || pinNumber > 1) return -1; |
| | | | |
| − | // find out the state of the led | + | // Trouver l'état de la Led dans la commande |
| | + | // SI l'état n'est pas identifié ALORS on quitte la fonction ledControl |
| | if(command.substring(3,7) == "HIGH") state = 1; | | if(command.substring(3,7) == "HIGH") state = 1; |
| | else if(command.substring(3,6) == "LOW") state = 0; | | else if(command.substring(3,6) == "LOW") state = 0; |
| | else return -1; | | else return -1; |
| | | | |
| − | // write to the appropriate pin | + | // Modifier l'état de la broche |
| | digitalWrite(pinNumber, state); | | digitalWrite(pinNumber, state); |
| | return 1; | | return 1; |