go_away

Author Topic: Polulu digital QTR reflectance sensors  (Read 5490 times)

0 Members and 1 Guest are viewing this topic.

Offline richiereynoldsTopic starter

  • Full Member
  • ***
  • Posts: 112
  • Helpful? 3
Polulu digital QTR reflectance sensors
« on: February 21, 2010, 05:49:49 PM »
Has anyone got these to work? I have a QTR-1RC (digital) and a QTR-1A (analogue). I can get the analogue one to work but the digital one is just returning a max value which amounts to a timeout or a reflectance of 0.

I've tried usng the pololu AVR library, which takes a little pin mapping etc. as it seems to be set up for the arduino, but I've also written my own charging, reading, discharging, timing code and with both methods I get values from the analogue one but nothing useful from the digital.

If anyone has some working code for the ATMEGA I'd love to see it so I can test if I've just got a dodgy piece of hardware.

Thanks, Richard.

Offline vinito

  • Full Member
  • ***
  • Posts: 101
  • Helpful? 6
Re: Polulu digital QTR reflectance sensors
« Reply #1 on: February 28, 2010, 12:51:18 AM »
Well I'll bump this one up because I seem to have the identical results with my QTR-8RC sensors. Either they got a huge batch of defective sensor elements, or our code doesn't do what they want us to do (more likely). I thought they explained how they work well enough to get something going, but I sure can't find any love.

Maybe someone will chime in and fix this up.
According to Pololu, this is the drill:
  1.  Turn on IR LEDs (optional)
   2. Set the I/O line to an output and drive it high
   3. Allow at least 10 us for the 10 nF capacitor to charge
   4. Make the I/O line an input (high impedance)
   5. Measure the time for the capacitor to discharge by waiting for the I/O line to go low
   6. Turn off IR LEDs (optional)


I'm skipping the "turn on LED" part just to simplify (i.e. always on). I did verify with a digital camera and all the LEDs are glowing nicely.

So since they don't say what, I was kind of shooting for a 20ms timeout just for overkill. I'm sending the output to serial print so I can snoop in to see what it's doing. Not much. I'll fudge with the numbers and it just shows timeout even at 2 seconds. Same drill no matter what I do. With a 1us loop I still get the timeout. It never goes to low.
Of course this is all according to the code I'm trying to use. I'm just skipping the libraries supplied by Pololu and trying my own very simple code just to see if I can get something figured out.
Seems like I read somewhere that Pololu's instructions were backwards from what you actually need to do, but I can't find that now and I don't know if that was true anyway.
So here's my setup and code:
QTR -------  Arduino
Vcc  -------  5V
Gnd -------  Gnd
Sensor1 --   Pin 0 Digital I/O

simple

It returns "high" no matter what I do, so either the capacitor isn't discharging like expected, I've wired it wrong, or my code is all screwed up.

And I hesitate to post this because I'm a moron newb at this, but here's the code I'm trying:
(Arduino, by the way)

(edit to remove code since it was non-working junk text anyway)
« Last Edit: March 01, 2010, 12:26:22 AM by vinito »

Offline vinito

  • Full Member
  • ***
  • Posts: 101
  • Helpful? 6
Success! (and a mystery) - Polulu Reflectance Sensor vs. Arduino
« Reply #2 on: February 28, 2010, 06:57:50 PM »
Well I did a little more experimenting and discovered something interesting.

First I explored Arduino to see if the digitalRead() function was working. Simplified the code to just read a pin and test for high/low. If I jumpered a pin to gnd and alternately to +5V, sure enough the pin would read 0 and 1 respectively. OK so the pin is not fried and the command works. But still no love with the sensor.

Then I tried other pins just for the hell of it. Luckily I skipped pin 1 and jumped to pin 2. Arduino pin 2 gave satisfactory results on the reflectance sensor with the same code! Switching back to pin 0 still kept timing out. Nothing I did when using this pin would work. Moved to pin 1 and it behaved just like pin 0. Switched to pin 2 again and presto! Pin 3 worked fine too. Pin 4 kind of worked but not very well - reflective surface didn't indicate as well and timed out a lot. Then pin 5 and it works as well as 2 and 3.

So there is apparently some internal impedance thing with either Arduino or the AVR chip itself. So try other pins and see what you get. I'm hoping there are enough working pins that this sensor could be utilized.

So here's the recipe that worked for me:
Wiring -
Arduino pin 2 to reflectance sensor output pin (one of any of the 8 in my case) (Arduino pin 2 and some others worked while others didn't)
Arduino +5V out to Sensor Vcc
Arduino GND to Sensor GND
cake!

And here's the code that seemed to give some satisfactory results. I would load the code, then click on the serial monitor on the Arduino IDE software.
It just gives a rolling list of values. The values will vary depending on what you plant in front of the sensor and it depends on the distance away from the sensor too.
I used a piece of standard white printer paper with a black line drawn on it with a sharpie marker. It worked well - indicated reliable contrast.

Code: [Select]
/*

 * demo code for the Pololu reflectance sensor by Vince Callahan


 * This code will display the value of sensor output on the serial port
 
   Arduino pin 2 to reflectance sensor output pin (any one of the 8)
   Arduino +5V out to Sensor Vcc
   Arduino GND to Sensor GND
  
   pin 2,3,5 work, 0,1,4 do NOT - more to be discovered with experimentation

 */

int sensor1 = 2;  // change "2" to whatever pin to which you are hooking the sensor. Just this one change allows you to test operation on other pins.
int reflectance;



// This function displays the sensor readings updated a few times per second.


void setup()

{
  // initialize the serial communications
  Serial.begin(9600);

}


void loop()

{

  reflectance = 1;                   //initialize value to 1 at the beginning of each loop
  pinMode(sensor1, OUTPUT);   //set pin as output
  digitalWrite(sensor1, HIGH);  //set pin HIGH (5V)
  delayMicroseconds(15);        //charge capacitor for 15 microseconds
  
  pinMode(sensor1, INPUT);                                          //set pin as input
     while((reflectance < 500) && (digitalRead(sensor1) != LOW)){   //timeout at 500
                                                                    // read the pin state, increment counter until state = LOW
          ++ reflectance;                                           // increment value to be displayed via serial port
              delayMicroseconds(4);                                 //Change value or comment out to adjust value range
      }
 
  if (reflectance < 500){
      Serial.println(reflectance);}   //Send reflectance value to serial display
      else {
        Serial.println("T.O.");       //if reflectance value is over 500 then it's a "timeout"
      }
      
  delay(100);
  
}

This is just simple code written to experiment with the sensor so I can then expand on it. Turns out you need something like this to use just to find suitable pins.


Ideally I think this sensor falls short of what it ought to be. The QTR-1 is not such an issue, but for the QTR-8 a little more circuitry could be utilized so the thing works reliably and sends out values in serial fashion so it doesn't take 8 MC pins. And as it is, the 8 pins need to be chosen correctly with experimentation (in my case anyway - a smart feller could figure out what this varying pin thing is about and use the right pins based on cold, hard engineering facts).

Also, 8 pins is a strange number anyway. Maybe they've thought this through and there is a reason, but from what I've seen the magic number for line-following robots is 5. Even if you optionally break off the two, you still have 6. This isn't a big deal and the code is just written to suit what you've got, but it would seem a better idea to just have 5 and only need to use a minimum of pins on your micro.

Seems to me they were trying to both pack in options and be inexpensive at the same time. That would be cool if it worked out, but I think the end result is a product which leaves me wishing for some features while providing more sensors that I needed or wanted in the first place. Might be great for the right application - just not mine.

In the end I figured it out, which was gratifying eventually. Hopefully this info is useful for other purchasers of the sensor.
« Last Edit: February 28, 2010, 07:02:39 PM by vinito »

Offline Razor Concepts

  • Supreme Robot
  • *****
  • Posts: 1,856
  • Helpful? 53
Re: Polulu digital QTR reflectance sensors
« Reply #3 on: February 28, 2010, 07:04:38 PM »
Pins 1 and 2 are used for serial communcation, you should not use them while using the Serial library.

Offline vinito

  • Full Member
  • ***
  • Posts: 101
  • Helpful? 6
Re: Polulu digital QTR reflectance sensors
« Reply #4 on: February 28, 2010, 07:19:47 PM »
Ahh. See there's somebody who knows something. Thanks - that makes sense now. I might have stumbled across that in the next six months, but maybe not.
I'm guessing something like that may be affecting pin 4 too.

So I'm not explicitly including the serial library, but I suppose Arduino does that by default since there is a Serial.print command?
And I would guess that maybe those pins would work if I wasn't trying to send values via serial com.

So maybe my recipe above will still be useful for folks who want to experiment and make some "sense" out of the sensor. Hopefully posting my mistakes here will edify the masses in some way.

Offline vinito

  • Full Member
  • ***
  • Posts: 101
  • Helpful? 6
The Pololu Way
« Reply #5 on: February 28, 2010, 10:06:09 PM »
Now that I troubleshooted my own simple code on my own I'll admit that it was good practice.
And now that I've done that, this post is showing the "Pololu Library" way of doing it even better.
http://www.societyofrobots.com/robotforum/index.php?topic=10463

Based on the code (and posted corrections) shown in that thread, I used the code below to test and display results similar to what I got from my own test, but with much better results. Plus it does a calibration routine first which would obviously be most helpful for dependable operation.

I edited it to work correctly with Arduino, and to work with 6 of the 8 sensors from a QTR-8RC sensor array. I've added comments to show where to edit depending on how many sensors you want to test.
There are FOUR (4) edits you need to make to adjust for a number of sensors other than 6. All 4 are noted inside the code.

Code: [Select]
#include <PololuQTRSensors.h>  
  
// create an object for your type of sensor (RC or Analog)  
// in this example we have six sensors on analog inputs 0 - 5, a.k.a. Arduino digital pins 14 - 19
PololuQTRSensorsRC qtr((unsigned char[]) {14, 15, 16, 17, 18, 19}, 6);  // edit to adjust for number of sensors and desired Arduino pins for connections
//i.e. {14, 15, 16, 17, 18, }, 5); - for only 5 pins - {2, 3, 14, 15, 16, 17, 18, 19}, 8); - for all 8 pins, etc.
  
void setup()  
{  
  // optional: wait for some input from the user, such as  a button press  
  
  // then start calibration phase and move the sensors over both  
  // reflectance extremes they will encounter in your application:  
  int i;  
  for (i = 0; i < 250; i++)  // make the calibration take about 5 seconds  
  {  
    qtr.calibrate();  
    delay(20);  
  }  
  
  // optional: signal that the calibration phase is now over and wait for further  
  // input from the user, such as a button press  
  
  Serial.begin(9600);
}  

void loop()  
{  
  unsigned int sensors[6];  // change 6 to whatever number of sensors you are using
  // get calibrated sensor values returned in the sensors array, along with the line position  
  // position will range from 0 to 2000, with 1000 corresponding to the line over the middle sensor  
  int position = qtr.readLine(sensors);  
  
// output to Serial monitor
Serial.print(sensors[0]);
Serial.print(" ");
Serial.print(sensors[1]);
Serial.print(" ");
Serial.print(sensors[2]);
Serial.print(" ");
Serial.print(sensors[3]);
Serial.print(" ");
Serial.print(sensors[4]);
Serial.print(" ");
Serial.print(sensors[5]);   // "comment out" this line and the one below to subtract a sensor. Do the same for more pairs above to subtract more sensors.
Serial.print(" ");              // read comment in line above this one
//Serial.print(sensors[6]); remove comment marks to add sensor 7 (and don't forget to "comment out" THIS comment - same for any of the three lines below this)
//Serial.print(" ");            remove comment marks to add sensor 7
//Serial.print(sensors[7]); remove comment marks to add sensor 8
//Serial.print(" ");            remove comment marks to add sensor 8
Serial.println();

  // if all six sensors see very low reflectance, take some appropriate action for this situation
  //add or subtract " && sensors[?] > 750" from line below depending on how many sensors you are using
  if (sensors[0] > 750 && sensors[1] > 750 && sensors[2] > 750 && sensors[3] > 750 && sensors[4] > 750 && sensors[5] > 750)
  {  
    // do something.  Maybe this means we're at the edge of a course or about to fall off a table,  
    // in which case, we might want to stop moving, back up, and turn around.  
    return;  
  }  
  
  // compute our "error" from the line position.  We will make it so that the error is zero when  
  // the middle sensor is over the line, because this is our goal.  Error will range from  
  // -1000 to +1000.  If we have sensor 0 on the left and sensor 2 on the right,  a reading of -1000  
  // means that we see the line on the left and a reading of +1000 means we see the line on  
  // the right.  
  int error = position - 1000;  
  
  int leftMotorSpeed = 100;  
  int rightMotorSpeed = 100;  
  if (error < -500)  // the line is on the left  
    leftMotorSpeed = 0;  // turn left  
  if (error > 500)  // the line is on the right  
    rightMotorSpeed = 0;  // turn right  
  
  // set motor speeds using the two motor speed variables above  
}  

Wire thusly:
QTR -----------  Arduino
Vcc  -----------  5V
Gnd -----------  Gnd
Sensor1 ------   Pin 14 - a.k.a. analog 0 I/O
Sensor2 ------   Pin 15 - a.k.a. analog 1 I/O
Sensor3 ------   Pin 16 - a.k.a. analog 2 I/O
Sensor4 ------   Pin 17 - a.k.a. analog 3 I/O
Sensor5 ------   Pin 18 - a.k.a. analog 4 I/O
Sensor6 ------   Pin 19 - a.k.a. analog 5 I/O
(Sensor7 -----   Pin 2)
(Sensor8 -----   Pin 3)

edit: Having written this post already, I don't know how this code will work right with only one sensor. I suspect it ought to work fine, but there is an "error handling" line toward the bottom that might cause problems if there is nothing to compare anything to. I think you could just comment that line out if there is an error. Just kind of guessing here.
« Last Edit: February 28, 2010, 10:12:58 PM by vinito »

Offline meenzal

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
Re: Polulu digital QTR reflectance sensors
« Reply #6 on: March 07, 2010, 04:14:47 PM »
I have three of the 1RC reflectance sensors and am trying to use the latest sketch show in this thread. So far, no luck. I'm using and Arduino Duemilanove with the sensors plugged into analog pins 3,4 and 5. I have inserted code to light an LED for 1 second if any of the sensors go non-zero. So far, the serial monitor just shows me row after row of "0 0 0" regardless of whatever I place in front of the sensors.

Here's the sketch with the changes I made. If anyone can help me with where I went wrong, I'd appreciate it.


Quote
#include <PololuQTRSensors.h> 

int ledPin = 13;

// create an object for your type of sensor (RC or Analog) 
// in this example we have six sensors on analog inputs 0 - 5, a.k.a. Arduino digital pins 14 - 19
PololuQTRSensorsRC qtr((unsigned char[]) {3,4,5}, 3);  // edit to adjust for number of sensors and desired Arduino pins for connections
//i.e. {14, 15, 16, 17, 18, }, 5); - for only 5 pins - {2, 3, 14, 15, 16, 17, 18, 19}, 8); - for all 8 pins, etc.
 
void setup() 
{
  pinMode(ledPin, OUTPUT);
 
  // optional: wait for some input from the user, such as  a button press 
 
  // then start calibration phase and move the sensors over both 
  // reflectance extremes they will encounter in your application: 
  int i; 
  for (i = 0; i < 250; i++)  // make the calibration take about 5 seconds 
  { 
    qtr.calibrate(); 
    delay(20); 
  } 
 
  // optional: signal that the calibration phase is now over and wait for further 
  // input from the user, such as a button press 
 
  Serial.begin(9600);


void loop() 

  unsigned int sensors[3];  // change 6 to whatever number of sensors you are using
  // get calibrated sensor values returned in the sensors array, along with the line position 
  // position will range from 0 to 2000, with 1000 corresponding to the line over the middle sensor 
  int position = qtr.readLine(sensors); 
 
// output to Serial monitor
Serial.print(sensors[0]);
Serial.print(" ");
Serial.print(sensors[1]);
Serial.print(" ");
Serial.print(sensors[2]);
Serial.print(" ");
//Serial.print(sensors[3]);
//Serial.print(" ");
//Serial.print(sensors[4]);
//Serial.print(" ");
//Serial.print(sensors[5]);   // "comment out" this line and the one below to subtract a sensor. Do the same for more pairs above to subtract more sensors.
//Serial.print(" ");              // read comment in line above this one
//Serial.print(sensors[6]); remove comment marks to add sensor 7 (and don't forget to "comment out" THIS comment - same for any of the three lines below this)
//Serial.print(" ");            remove comment marks to add sensor 7
//Serial.print(sensors[7]); remove comment marks to add sensor 8
//Serial.print(" ");            remove comment marks to add sensor 8
Serial.println();

  // if all six sensors see very low reflectance, take some appropriate action for this situation
  //add or subtract " && sensors[?] > 750" from line below depending on how many sensors you are using
  if (sensors[0] > 750 && sensors[1] > 750 && sensors[2] > 750)
  { 
   digitalWrite(ledPin, HIGH);  // turn on an LED for a second to indicate reflectance drop
   delay(1000);
   digitalWrite(ledPin, LOW);
    // do something.  Maybe this means we're at the edge of a course or about to fall off a table, 
    // in which case, we might want to stop moving, back up, and turn around. 
    return; 
  } 
 
  // compute our "error" from the line position.  We will make it so that the error is zero when 
  // the middle sensor is over the line, because this is our goal.  Error will range from 
  // -1000 to +1000.  If we have sensor 0 on the left and sensor 2 on the right,  a reading of -1000 
  // means that we see the line on the left and a reading of +1000 means we see the line on 
  // the right. 
  int error = position - 1000; 
 
  int leftMotorSpeed = 100; 
  int rightMotorSpeed = 100; 
  if (error < -500)  // the line is on the left 
    leftMotorSpeed = 0;  // turn left 
  if (error > 500)  // the line is on the right 
    rightMotorSpeed = 0;  // turn right 
 
  // set motor speeds using the two motor speed variables above 
}

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
Re: Polulu digital QTR reflectance sensors
« Reply #7 on: March 07, 2010, 06:18:41 PM »
Compare your sensors definition:
Code: [Select]
PololuQTRSensorsRC qtr((unsigned char[]) {3,4,5}, 3);  // edit to adjust for number of sensors and desired Arduino
with vinito's sensors definition:
Code: [Select]
PololuQTRSensorsRC qtr((unsigned char[]) {14, 15, 16, 17, 18, 19}, 6);  // edit to adjust for number of sensors and desired Arduino pins for connections

and here is his description of how you should do it:
Code: [Select]
// in this example we have six sensors on analog inputs 0 - 5, a.k.a. Arduino digital pins 14 - 19

The Pololu qtr library expects you to define the pins as digital, not analog.
Check out the uBotino robot controller!

Offline meenzal

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
Re: Polulu digital QTR reflectance sensors
« Reply #8 on: March 07, 2010, 09:05:20 PM »
I changed the definition to

PololuQTRSensorsRC qtr((unsigned char[]) {17,18,19}, 3);  //eg: analog 3,4,5

and I get the same "0 0 0" result.


Offline vinito

  • Full Member
  • ***
  • Posts: 101
  • Helpful? 6
Re: Polulu digital QTR reflectance sensors
« Reply #9 on: March 07, 2010, 10:10:22 PM »
This might be a stupid question, but after changing the definition, did you also change the wiring?
The way I wired mine:

Arduino -------- QTR
+5V                VCC (or VIN)
GND               GND
Analog In 3      Sensor Output Pin
Analog In 4      Sensor Output Pin
Analog In 5      Sensor Output Pin


It would be worth double-checking. In fact, more often than not I seem to have at least one wire in the wrong place. I guess if I knew anything I'd be embarrassed to say that, but I can always edit this later once I learn better. ;)
« Last Edit: March 07, 2010, 10:16:32 PM by vinito »

Offline vinito

  • Full Member
  • ***
  • Posts: 101
  • Helpful? 6
Re: Polulu digital QTR reflectance sensors
« Reply #10 on: March 07, 2010, 10:27:03 PM »
I think I know what might be happening!
When you reset the Arduino, for a few seconds the thing first does a calibration for the sensors. You must hold something close in front of the sensors and move it back & forth (your fingertip will do) while it's in the calibration phase. After a few seconds, the board will begin streaming data to your serial monitor, which is the indication that the calibration has finished and you can now rest your fingertip and enjoy the data stream. If you don't give it something to reflect on (hehe) during calibration, it WILL just send nuttin' but zeros to the serial monitor.

Try that if you haven't already.
« Last Edit: March 07, 2010, 10:42:39 PM by vinito »

Offline meenzal

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
Re: Polulu digital QTR reflectance sensors
« Reply #11 on: March 08, 2010, 04:17:25 PM »
I did check the wiring and all seems fine. I took a photo of the breadboard and I can see the IR leds all shining. I've checked and rechecked, and I'm just plain stumped.

I tried resetting and moving my hand back and forth in front of the sensors, still no joy. It won't produce anything but a zero for each of the sensor outputs.

Here's a photo. You can see that the leds are lit, so power wires are correct and that leaves just the white wires going to the Arduino, and they are plugged in where they should be as near as I can tell. Like I said, I'm stumped.






Offline vinito

  • Full Member
  • ***
  • Posts: 101
  • Helpful? 6
Re: Polulu digital QTR reflectance sensors
« Reply #12 on: March 09, 2010, 12:03:26 AM »
Man I don't know what to tell ya. Looks like it's connected correctly.
You're communicating to the serial monitor properly otherwise you would get nuthin' at all.
The code I posted was lifted from this post:
http://www.societyofrobots.com/robotforum/index.php?topic=10463
(4th post down - the first box is the code, the second is something else)
You might try lifting that directly or something. That post mentions the Pololu-supplied library, which needs to be in the right Arduino folder for it to work. But I suspect you must have the library installed OK otherwise I would expect errors to show in the compile.

It seems to me that there must be a glitch in the code. If you're using Arduino Analog pins 3,4,5 then make sure the code is correct.
This worked with three sensors for me:

Code: [Select]
#include <PololuQTRSensors.h>  
  
// create an object for your type of sensor (RC or Analog)  
// in this example we have three sensors on analog inputs 3 - 5, a.k.a. Arduino digital pins 17 - 19
PololuQTRSensorsRC qtr((unsigned char[]) {17, 18, 19}, 3);

  
void setup()  
{
  // start calibration phase and move the sensors over both  
  // reflectance extremes they will encounter in your application:  
  int i;  
  for (i = 0; i < 250; i++)  // make the calibration take about 5 seconds  
  {  
    qtr.calibrate();  
    delay(20);  
  }  
  
  Serial.begin(9600);
   Serial.println();
   Serial.println("CALIBRATION COMPLETE");
   Serial.println();
   delay(1000);
}  

void loop()  
{  
  unsigned int sensors[3];  // for three sensors
  // get calibrated sensor values returned in the sensors array, along with the line position  
  // position will range from 0 to 2000, with 1000 corresponding to the line over the middle sensor  
  int position = qtr.readLine(sensors);  
  
// output to Serial monitor
Serial.print(sensors[0]);
Serial.print(" ");
Serial.print(sensors[1]);
Serial.print(" ");
Serial.print(sensors[2]);
Serial.print(" ");
Serial.println();

  // if all sthree sensors see very low reflectance, print the string "no reflectance seen"
  if (sensors[0] > 750 && sensors[1] > 750 && sensors[2])
  {  
    Serial.println ("NO REFLECTANCE SEEN");
    return;  
  }  
}  

Note the line:
PololuQTRSensorsRC qtr((unsigned char[]) {17, 18, 19}, 3);

digital pins 17,18,19 are labeled "Analog In" 3,4 & 5 on the Arduino board. It's difficult to tell from the photo exactly which inputs you've wired, but it looks like you're in Analog 3,4 & 5. That should work fine with this code.

I'm green with this stuff so I could certainly be mistaken, but I think if you define those inputs as 3,4 & 5 then it will be looking at the Digital pins 3,4 & 5 on the opposite edge of the board. That will indeed send a stream of zeros unless the sensor outputs are plugged into those Arduino Digital inputs.

I feel like I'm being confusing, but it's late and that's the best I can do in this particular insomniac moment.
« Last Edit: March 09, 2010, 12:34:19 AM by vinito »

Offline meenzal

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
Re: Polulu digital QTR reflectance sensors
« Reply #13 on: March 09, 2010, 12:53:29 PM »
I appreciate the help. I did have the pins marked as 3,4, and 5 and was advised to change them to 17, 18, and 19, which I did. I am plugged into analog 3.4. and 5. The Pololu libraries are in and recognized, else the qtr.xxx() functions would indeed error out.

I'll lift the code as you suggest --maybe there's something in there we just aren't seeing. I'm also giving thought to trying just a single sensor instead of the array. That would simplify the sketch and make each thing easier to trace.

It's weird, for sure. If I get it figured out, I'll post it for others to see.

Offline vinito

  • Full Member
  • ***
  • Posts: 101
  • Helpful? 6
Re: Polulu digital QTR reflectance sensors
« Reply #14 on: March 10, 2010, 02:17:06 AM »
Yea I'd like to know what the problem ended up to be if you figure it out. Since you have three and they all act the same, I think we can pretty safely rule out a defective sensor.
You do have the digital (QTR-1RC) and not the analog (QTR-1A) sensors don't you? I don't know how you'd test the analog ones since I haven't gone that route as yet. Maybe it's the same code - I wouldn't know. I imagine you know what you've got - I'm just trying to cover the bases.

If the code I posted in the previous thread (for three sensors) doesn't work I sure don't know what could be wrong. After I verified proper operation with my Arduino, I copied and pasted it directly to that post. It was sending a nice, smooth data stream to the serial monitor. My Arduino is one generation ago, but I don't think the newer one would function any differently. If the code doesn't work and it's wired correctly, then I would wonder if one of the standard Arduino libraries was edited at some point previous for a different project or something - like maybe the timing or delays are funky or the like.

That's putting the cart before the horse though. Hopefully it just works.
« Last Edit: March 10, 2010, 02:19:17 AM by vinito »

Offline Halpzzz

  • Beginner
  • *
  • Posts: 1
  • Helpful? 0
Re: Polulu digital QTR reflectance sensors
« Reply #15 on: May 19, 2010, 10:48:07 AM »
I just got a few QTR-1RC sensors and an arduino dem. board too. Im trying to make something that senses proximity and lights up an led. Very basic but I'm brand new to C... i used Basicstamp stuff in highschool alot and iv looked into C. it seems ill pick up pretty quickly. But would anybody know a basic starter program to run for this to help base myself?
Doesnt have to get brighter with closer porximity or anything just turn on when my hand or anything else gets close. Any help GREATLY appreciate.

-Sean

 


Get Your Ad Here

data_list