Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
146
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None
  1. #include <QTRSensors.h>
  2.  
  3. #define NUM_SENSORS 1 // number of sensors used
  4. #define TIMEOUT 2500 // waits for 2500 microseconds for sensor outputs to go low
  5. #define EMITTER_PIN QTR_NO_EMITTER_PIN // emitter is controlled by digital pin 2
  6.  
  7. QTRSensorsRC qtrrc((unsigned char[]) {8},
  8. NUM_SENSORS, TIMEOUT, EMITTER_PIN);
  9. unsigned int sensorValues[NUM_SENSORS];
  10.  
  11.  
  12. void setup()
  13. {
  14. delay(500);
  15. Serial.begin(9600); // set the data rate in bits per second for serial data transmission
  16. delay(1000);
  17. }
  18.  
  19.  
  20. void loop()
  21. {
  22. // read raw sensor values
  23. qtrrc.read(sensorValues);
  24.  
  25. // print the sensor values as numbers from 0 to 2500, where 0 means maximum reflectance and
  26. // 2500 means minimum reflectance
  27. for (unsigned char i = 0; i < NUM_SENSORS; i++)
  28. {
  29. Serial.print(sensorValues[i]);
  30. Serial.print('\t'); // tab to format the raw data into columns in the Serial monitor
  31. }
  32. Serial.println();
  33.  
  34. delay(250);
  35. }
Advertisement
RAW Paste Data Copied
Advertisement