Modifications

Sauter à la navigation Sauter à la recherche
aucun résumé de modification
Ligne 30 : Ligne 30 :  
</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 Section 3.
+
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]].
    
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.
    
Several example sketches are available to help you get started. To view the example sketches, open the Arduino IDE and navigate to:
 
Several example sketches are available to help you get started. To view the example sketches, open the Arduino IDE and navigate to:
 +
 +
'''File > Examples > QTRSensors'''
 +
 +
As a first step, we recommend using '''QTRARawValuesExample''' (for QTR-xA sensors) or '''QTRRCRawValuesExample''' (for the QTR-xRC sensors). These examples will simply print the raw readings from the sensors to the serial monitor, using 9600 baud. Once that is working, you might want to try one of the more advanced examples, '''QTRAExample''' or '''QTRRCExample''', which incorporate calibration and also estimate the position of a line.
 +
    
{{Pololu-Senseur-QTR-TRAILER}}
 
{{Pololu-Senseur-QTR-TRAILER}}
29 918

modifications

Menu de navigation