Modifications

Sauter à la navigation Sauter à la recherche
Ligne 18 : Ligne 18 :  
Si vous ne disposez pas du gestionnaire de bibliothèque, vous pouvez l'installer manuellement.
 
Si vous ne disposez pas du gestionnaire de bibliothèque, vous pouvez l'installer manuellement.
   −
If this does not work, you can manually install the library:
+
{{download-box|Téléchargez QTRSensors.zip|https://github.com/pololu/qtr-sensors-arduino/archive/master.zip}}
# Download the [https://github.com/pololu/qtr-sensors-arduino/releases latest release archive from GitHub] and decompress it.
  −
# Rename the folder “qtr-sensors-arduino-xxxx” to “QTRSensors”.
  −
# Drag the “QTRSensors” folder into the “libraries” directory inside your Arduino sketchbook directory. You can view your sketchbook location by opening the “File” menu and selecting “Preferences” in the Arduino IDE. If there is not already a “libraries” folder in that location, you should make the folder yourself.
  −
# After installing the library, restart the Arduino IDE.
     −
You should now be able to use these libraries in your sketches by selecting '''Sketch > Import Library > QTRSensors''' from your Arduino IDE (or simply type {{fname|#include <QTRSensors.h>}} at the top of your sketch). Note that you might need to restart your Arduino IDE before it sees the new libraries.
+
# Télécharger la [https://github.com/pololu/qtr-sensors-arduino/releases dernière version de l'archive depuis GitHub] (voir aussi le lien ci-dessus) et la décompresser.
 +
# Renommer le répertoire "qtr-sensors-arduino-xxxx" vers "QTRSensors".
 +
# Ensuite, placer le répertoire "QTRSensors" dans le répertoire des bibliothèque (''libraries'') du répertoire contenant vos croquis arduino.<br />Pour localiser facilement ce répertoire en sélectionnant le point de menu "Fichier | Préférences" dans Arduino IDE. S'il n'y a pas encore de sous répertoire "libraries" à cette position alors il sera nécessaire de le créer avant d'y déplacer QTRSensors.
 +
# Redémarrer Arduino IDE après installer la biblothèque.
   −
Once this is done, you can create a '''QTRSensorsAnalog''' object for your QTR-xA sensors and a '''QTRSensorsRC''' object for your QTR-xRC sensors:
+
== Tester la bibliothèque ==
 +
Un fois la bibliothèque installé, vous pouvez l'intégrer dans votre croquis en sélectionnant le point de menu "Croquis | Importer bibliothèque | QTRSensors" depuis votre Arduino IDE (ou saisissez simplement {{fname|#include <QTRSensors.h>}} en haut de votre croquis).
 +
 
 +
{{ambox|text=Notez qu'il serait probablement nécessaire de redémarrer Arduino IDE avant de pouvoir coir la nouvelle bibliothèque.}}
 +
 
 +
Une fois fait, vous pouvez créer:
 +
* pour un senseur QTR-xA : un objet '''QTRSensorsAnalog''' destiné au senseur analogique (mesure de tension).
 +
* pour un senseur QTR-xRC : un objet '''QTRSensorsRC''' destiné au senseur digital (mesure de temps).
    
<syntaxhighlight lang="C">
 
<syntaxhighlight lang="C">
// create an object for three QTR-xA sensors on analog inputs 0, 2, and 6
+
// Créer un objet pour 3 senseurs QTR-xA sur les
 +
// entrées analogique 0, 2 et 6
 
QTRSensorsAnalog qtra((unsigned char[]) {0, 2, 6}, 3);
 
QTRSensorsAnalog qtra((unsigned char[]) {0, 2, 6}, 3);
 
   
 
   
// create an object for four QTR-xRC sensors on digital pins 0 and 9, and on analog
+
// Créer un objet pour senseurs QTR-xRC sur les
// inputs 1 and 3 (which are being used as digital inputs 15 and 17 in this case)
+
// entrées digitales 0 et 9 ainsi que sur les
 +
// entrée analogiques 1 et 3 (qui sont utilisées
 +
// en tant qu'entrée digitale 15 et 17)
 
QTRSensorsRC qtrrc((unsigned char[]) {0, 9, 15, 17}, 4);
 
QTRSensorsRC qtrrc((unsigned char[]) {0, 9, 15, 17}, 4);
 
</syntaxhighlight>
 
</syntaxhighlight>
   −
This library takes care of the differences between the QTR-xA and QTR-xRC sensors internally, providing you with a common interface to both sensors. The only external difference is in the constructors, as you can see in the code sample above. The first argument to the QTRSensorsAnalog constructor is an array of analog input pins (0 – 7) while the first argument to the QTRSensorsRC constructor is an array of digital pins (0 – 19). Note that analog inputs 0 – 5 can be used as digital pins 14 – 19. For more details, see [[Pololu-Senseur-QTR-Utiliser|utilisation et notes]].
+
Cette bibliothèque prend en charge -en interne- les différences entre les senseurs QTR-xA et QTR-xRC. Grâce à la bibliothèque vous disposez d'une interface commune pour les deux types de senseur. Comme vous pouvez le constater dans le code d'exemple ci-dessus, la seule différence se trouve au niveau du constructeur.  
 +
 
 +
Le premier argument du constructeur {{fname|QTRSensorsAnalog}} est un tableur de broche analogique (0 – 7) alors que le premier argument du constructeur {{fname|QTRSensorsRC}} est un tableau de broche digital (0 – 19).  
 +
 
 +
Note that analog inputs 0 – 5 can be used as digital pins 14 – 19. For more details, see [[Pololu-Senseur-QTR-Utiliser|utilisation et notes]].
    
The only other difference you might experience is in the time it takes to read the sensor values. The QTR-xRC sensors can all be read in parallel, but each requires the timing of a pulse that might take as long as 3 ms (you can specify how long the library should time this pulse before timing out and declaring the result full black). The QTR-xA sensors use the analog-to-digital converter (ADC) and hence must be read sequentially. Additionally, the analog results are produced by internally averaging a number of samples for each sensor (you can specify the number of samples to average) to decrease the effect of noise on the results.
 
The only other difference you might experience is in the time it takes to read the sensor values. The QTR-xRC sensors can all be read in parallel, but each requires the timing of a pulse that might take as long as 3 ms (you can specify how long the library should time this pulse before timing out and declaring the result full black). The QTR-xA sensors use the analog-to-digital converter (ADC) and hence must be read sequentially. Additionally, the analog results are produced by internally averaging a number of samples for each sensor (you can specify the number of samples to average) to decrease the effect of noise on the results.
29 917

modifications

Menu de navigation