Grrr reflectance sensors

 

 

Ok i have these on my chess robot but dont remember what i had to do to get them to work. It is the pololu digital line sensor http://www.pololu.com/catalog/product/959. Im using a arduino and 4 1.2v batteries. Here is my code. Please i forgot how to use these.

 

 

int sensor= 4;

int x;

void setup(){

pinMode (sensor, INPUT);

digitalWrite(sensor, HIGH);

delay(15);

Serial.begin(9600);

}

 

void loop(){

x= digitalRead(sensor);

Serial.println(x);

}

 

Try this out: int sensor=

Try this out:

int sensor= 4;

int x;

void setup(){

Serial.begin(9600);

}

 

void loop(){

pinMode (sensor, OUTPUT);

digitalWrite(sensor, HIGH);

delayMicroseconds(15);

pinMode (sensor, INPUT);

digitalWrite(sensor, LOW);

delayMicroseconds(800); //Adjust this value to tweak the threshold

x= digitalRead(sensor);

Serial.println(x);

}

#include <PololuQTRSensors.h

  1. #include <PololuQTRSensors.h>
  2. // create an object for your type of sensor (RC or Analog)
  3. // in this example we have three sensors on analog inputs 0 - 2, a.k.a. digital pins 14 - 16
  4. PololuQTRSensorsRC qtr((char[]) {14, 15, 16}, 3); --------------------ERROR HERE ********
  5. // PololuQTRSensorsA qtr((char[]) {0, 1, 2}, 3);
  6. void setup()
  7. {
  8. // optional: wait for some input from the user, such as a button press
  9. // then start calibration phase and move the sensors over both
  10. // reflectance extremes they will encounter in your application:
  11. int i;
  12. for (i = 0; i < 250; i++) // make the calibration take about 5 seconds
  13. {
  14. qtr.calibrate();
  15. delay(20);
  16. }
  17. // optional: signal that the calibration phase is now over and wait for further
  18. // input from the user, such as a button press
  19. }
the error is in the conversion from char to unsigned char it says