Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <QTRSensors.h>
- #define NUM_SENSORS 1 // number of sensors used
- #define TIMEOUT 2500 // waits for 2500 microseconds for sensor outputs to go low
- #define EMITTER_PIN QTR_NO_EMITTER_PIN // emitter is controlled by digital pin 2
- QTRSensorsRC qtrrc((unsigned char[]) {8},
- NUM_SENSORS, TIMEOUT, EMITTER_PIN);
- unsigned int sensorValues[NUM_SENSORS];
- void setup()
- {
- delay(500);
- Serial.begin(9600); // set the data rate in bits per second for serial data transmission
- delay(1000);
- }
- void loop()
- {
- // read raw sensor values
- qtrrc.read(sensorValues);
- // print the sensor values as numbers from 0 to 2500, where 0 means maximum reflectance and
- // 2500 means minimum reflectance
- for (unsigned char i = 0; i < NUM_SENSORS; i++)
- {
- Serial.print(sensorValues[i]);
- Serial.print('\t'); // tab to format the raw data into columns in the Serial monitor
- }
- Serial.println();
- delay(250);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement