| Ligne 57 : |
Ligne 57 : |
| | void setup() | | void setup() |
| | { | | { |
| − | // Play a little welcome song | + | // Jouer une petite chanson d'acceuil |
| | buzzer.play(">g32>>c32"); | | buzzer.play(">g32>>c32"); |
| | | | |
| − | // Initialize the reflectance sensors module | + | // Initialise le réseau de senseur infrarouge |
| | reflectanceSensors.init(); | | reflectanceSensors.init(); |
| | | | |
| − | // Wait for the user button to be pressed and released | + | // Attendre que le bouton utilisateur soit pressé et relâché |
| | button.waitForButton(); | | button.waitForButton(); |
| | | | |
| − | // Turn on LED to indicate we are in calibration mode | + | // Allumer la LED et pour indiquer que l'on est en mode calibration |
| | pinMode(13, OUTPUT); | | pinMode(13, OUTPUT); |
| | digitalWrite(13, HIGH); | | digitalWrite(13, HIGH); |
| | | | |
| − | // Wait 1 second and then begin automatic sensor calibration | + | // Attendre 1 seconde puis démarrer la calibration automatique |
| − | // by rotating in place to sweep the sensors over the line | + | // du senseur en faisant des rotations sur place pour faire passer |
| | + | // le senseur au dessus de la ligne |
| | delay(1000); | | delay(1000); |
| | int i; | | int i; |
| Ligne 82 : |
Ligne 83 : |
| | reflectanceSensors.calibrate(); | | reflectanceSensors.calibrate(); |
| | | | |
| − | // Since our counter runs to 80, the total delay will be | + | // Puisque notre compteur va jusque 80, le délais total sera de |
| | // 80*20 = 1600 ms. | | // 80*20 = 1600 ms. |
| | delay(20); | | delay(20); |
| Ligne 88 : |
Ligne 89 : |
| | motors.setSpeeds(0,0); | | motors.setSpeeds(0,0); |
| | | | |
| − | // Turn off LED to indicate we are through with calibration | + | // Eteindre la LED pour indiquer que nous avons terminé la calibration |
| | digitalWrite(13, LOW); | | digitalWrite(13, LOW); |
| | buzzer.play(">g32>>c32"); | | buzzer.play(">g32>>c32"); |
| | | | |
| − | // Wait for the user button to be pressed and released | + | // Attendre que le bouton utilisateur soit pressé et relâché |
| | button.waitForButton(); | | button.waitForButton(); |
| | | | |
| − | // Play music and wait for it to finish before we start driving. | + | // Jouer la musique et attendre qu'elle soit finie pour |
| | + | // commencer le pilotage. |
| | buzzer.play("L16 cdegreg4"); | | buzzer.play("L16 cdegreg4"); |
| | while(buzzer.isPlaying()); | | while(buzzer.isPlaying()); |
| Ligne 104 : |
Ligne 106 : |
| | unsigned int sensors[6]; | | unsigned int sensors[6]; |
| | | | |
| − | // Get the position of the line. Note that we *must* provide the "sensors" | + | // Obtenir la position de la ligne. Notez qu'il FAUT fournit le senseur "sensors" |
| − | // argument to readLine() here, even though we are not interested in the | + | // en argument à la fonction readLine(), même si nous ne sommes intéressé |
| − | // individual sensor readings | + | // par les lectures individuelles des différents senseurs. |
| | int position = reflectanceSensors.readLine(sensors); | | int position = reflectanceSensors.readLine(sensors); |
| | | | |
| − | // Our "error" is how far we are away from the center of the line, which | + | // L'erreur ("error") est la distance par rapport au centre de la ligne, qui |
| − | // corresponds to position 2500. | + | // correspond à la position 2500. |
| | int error = position - 2500; | | int error = position - 2500; |
| | | | |
| − | // Get motor speed difference using proportional and derivative PID terms | + | // Calculer la différence de vitesse entre les moteurs en utilisant un |
| − | // (the integral term is generally not very useful for line following). | + | // les termes proportionnels et dérivés du régulateur PID. |
| − | // Here we are using a proportional constant of 1/4 and a derivative | + | // (Le terme intégral n'est généralement pas très utile dans le |
| − | // constant of 6, which should work decently for many Zumo motor choices. | + | // suivit de ligne). |
| | + | // Nous utiliserons 1/4 pour la constante proportionnelle et 6 pour la |
| | + | // constante dérivée 6, qui devrait fonctionner correctement avec de |
| | + | // nombreux choix de Zumo. |
| | // You probably want to use trial and error to tune these constants for | | // You probably want to use trial and error to tune these constants for |
| | // your particular Zumo and line course. | | // your particular Zumo and line course. |