QTRSensorsAnalog does not name a type

I have a QTR-8A sensor but when I use the code given on the page: https://www.pololu.com/docs/0J19/all
The arduino program gives an error: ‘QTRSensorsA’ does not name a type
I installed the QTRSensor library as stated on that page, both via the manage library tab and via GitHub.
Can someone help me why I still get the error?
Thanks in advance

Code:

#include <QTRSensors.h>


QTRSensorsA qtr((unsigned char[]) {0, 2, 6}, 3);

void setup()
{
  int i;
  for (i = 0; i < 250; i++)  // make the calibration take about 5 seconds
  {
    qtr.calibrate();
    delay(20);
  }
}

void loop()
{
  unsigned int sensors[3];
  int position = qtr.readLine(sensors);
 
  if (sensors[0] > 750 && sensors[1] > 750 && sensors[2] > 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;
  }
 
  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
}

Hello.

We recently rewrote our QTR sensor Arduino library, so that document you are using is no longer accurate.

This update was fairly significant and changed the way the library functions, so you should make sure you have the current version of the QTR reflectance sensor library. Then, you can refer to the updated QTRSensors library documentation here. I recommend starting with the examples to make sure everything is working correctly.

Brandon

Hey Brandon,

Thank you for your reply.

I did what you said and downloaded the current version of the QTR sensor library. Then I started everything back up again. Then I started a example but I still got the same error: ‘QTRSensorsAnalog’ does not name a type.
(you can see it in the photo)

As far as I know, I did nothing wrong. Do you have another solution for this error, because I cannot find anything for this error.

Tom

The code shown in your screenshot is the example from the old library. If you updated the library successfully, you should be seeing the new QTRARawValuesExample program when you open it from the File > Examples > QTRSensors drop-down menu.

Could you open your Library Manager (Sketch > Include Lirbary > Manage Libraries…) and check what version your QTRSensors library is showing? It should show version 4.0.0 and look like this:

Brandon

1 Like

Hey Brandon,
I am also facing the same error, I have downloaded the latest version but it is still showing ‘QTRSensorsAnalog’ does not name a type.

Hello, sumit.

As I mentioned in my previous posts, we made a significant update to that library that changed the way it functions. Did you update the library from a previous build or were you installing it for the first time? Could you check your Library Manager and compare it to the screenshot in my preivous post?

Also, what code are you using? If you are not using one of the examples from the library, can you try one of those from the File > Examples > QTRSensors drop-down menu?

Please note that if you are using your own code that was written before the update, you will need to modify it if you want it to be compatible with the new library. If this is the case and you are having problems doing that, could you post what you have so far?

Brandon

1 Like

Im also having the same problem . I have updated the library everything is don but still the error exists

can you please resolve the issue within a day. i need to submit my project by monday

We removed the QTRSensorsAnalog, QTRSensorsRC, QTRDimmableAnalog, and QTRDimmableRC classes in the latest version of the library (4.0.0), which was released on 15 Mar 2019. If you have code that uses those classes, you might consider adapting your code to work with the new version, or installing an earlier version of the library (like 3.1.0). You can install previous versions of the library using the Library Manger by selecting the desired version and clicking the “Install” button.

Brandon

123.ino (3.9 KB)
i have attached my arduino file. can you please check and say where it is wrong?
iam getting the sensor readings wrong. Im not getting 6000 ,8000 like that for 8 sensors im using. Im getting values 0,1000,3000 only. it is reading a position of 5000 maximum only

I would generally suggest testing your line sensor separately using one of the unmodified example programs to make sure it is working correctly; however, it looks like you are trying to use pins 7, 8, 9, and 10 for motor control and your line sensor readings. They are probably interfering with each other and throwing your readings off, so you should try fixing this pin conflict first. Then, if you are still getting strange behavior, you can test them with the examples.

Brandon

im using different pins only. for sensors im using analog pins of arduino uno and for motor digital pins.
i have tested using example also the position value is not getting properly and it is showing a maximum of 4000-5000 only. but im using 8 sensors so it should show greater value. please help me out

I double checked your program (with all of the motor control code commented out) as well as the library’s example programs on my setup here and they worked fine for me, so I suspect the problem you are having is either with your setup or your process. When your system is calibrating the sensors, are you being sure to pass every sensor over the line so it can get good calibration readings? Also, could you post your updated code?

Could you test your QTR sensor separately by running the “QTRRCRawValuesExample” sketch and then post the output from the Serial Monitor here (preferably showing the sensor readings as the line passes under each sensor)? You will need to change the pin numbers used to match your current setup.

Brandon

hgjg.ino (3.9 KB)
now im getting the sensor readings but my robot is not able to follow the line.
iam using a l293d motor driver . just once say how to vary the speeds with this driver. is my code correct for this driver

We do not manufacture or carry any L293D-based motor driver boards, so we do not have any code specifically written for one. You might consider checking the datasheet, particularly looking for a truth table, to get an idea of how your driver works.

The L293D is a relatively old driver. If you are looking for a replacement that can use a simpler 2-pin (speed/direction) interface, you might consider something like our DRV8835 dual motor driver carrier, which is also available in a compact Arduino shield form factor.

We also have an Arduino library for the DRV8835 shield to make it easy to interface with the board.

Brandon