QTR-1A Reflectance Sensor Calibration


Im building a mini-sumo and Im using the QTR-1A Reflectance Sensor so my robot doesnt get out from the battle ground, but Im having problems withs the sensors readings.

float right,left;
//1 - Black
//0 - White

void setup(){

//Motors Pins
  pinMode(2,OUTPUT); //BIN1 
  pinMode(3,OUTPUT); //BIN2
  pinMode(4,OUTPUT); //AIN1
  pinMode(5,OUTPUT); //AIN2

void loop(){

left = analogRead(A4)*0.0048828125; 
right = analogRead(A5)*0.0048828125; 
if (left>=1){
if (right>=1){

Thats the code for Arduino UNO to test the sensor readings, i need to know how to calibrate them, and make the sensors to take correct readings.

I own the QTR with digital output, my question is do they need to be calibrated anytime I power the arduino, because in sumo battles you cant be calibratring anytime you reset.



It seems like your question is about the QTR-1A, but I think you mention the QTR-1RC at the end of your post. Which one is your question about? Do you have both?

Take a look at the first 3pi line following video in the 3pi videos page. Right at the beginning the 3pi calibrates itself by moving the IR sensors from dark to light. It stores the maximum and minimum values it sees to have a sense for the range of values it will encounter.

I think that there is a pretty good chance that you will not need to do that kind of thing though. My first suggestion would be to stop using floats because there is not benefit to doing it and it is likely confusing things and slowing down the CPU. Then, make a program that lights an LED when the sensor detects the white edge ring. You can probably do this with something like:

unsigned int left = analogRead(A4);
if (left < 50) 
  // light LED;

You will need to play around with the 50 number a bit to get something that doesn’t trigger on the black and does trigger immediately in the white.

Please let me know how that goes or if you have any additional questions.

- Ryan