PololuQTRA Arduino Example Does NOT Work

I was trying the PololuQTRAExample on UNO for one QTR-1A sensor. Since I only use one sensor, I modified the example sketch accordingly. I received the following errors while compiling. Can anybody advise what happend? Is there any incompability between the Pololu Arduino library and Uno?

D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp:36:24: error: WConstants.h: No such file or directory
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp: In member function ‘void PololuQTRSensors::emittersOff()’:
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp:125: error: ‘OUTPUT’ was not declared in this scope
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp:125: error: ‘pinMode’ was not declared in this scope
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp:126: error: ‘LOW’ was not declared in this scope
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp:126: error: ‘digitalWrite’ was not declared in this scope
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp: In member function ‘void PololuQTRSensors::emittersOn()’:
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp:133: error: ‘OUTPUT’ was not declared in this scope
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp:133: error: ‘pinMode’ was not declared in this scope
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp:134: error: ‘HIGH’ was not declared in this scope
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp:134: error: ‘digitalWrite’ was not declared in this scope
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp: In member function ‘void PololuQTRSensorsRC::readPrivate(unsigned int*)’:
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp:430: error: ‘HIGH’ was not declared in this scope
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp:430: error: ‘digitalWrite’ was not declared in this scope
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp:431: error: ‘OUTPUT’ was not declared in this scope
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp:431: error: ‘pinMode’ was not declared in this scope
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp:434: error: ‘delayMicroseconds’ was not declared in this scope
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp:438: error: ‘INPUT’ was not declared in this scope
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp:438: error: ‘pinMode’ was not declared in this scope
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp:439: error: ‘LOW’ was not declared in this scope
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp:439: error: ‘digitalWrite’ was not declared in this scope
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp:442: error: ‘micros’ was not declared in this scope
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp:448: error: ‘digitalRead’ was not declared in this scope
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp:448: error: ‘LOW’ was not declared in this scope
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp: In member function ‘void PololuQTRSensorsAnalog::readPrivate(unsigned int*)’:
D:\Program Files\arduino-1.0-windows\arduino-1.0\libraries\PololuQTRSensors\PololuQTRSensors.cpp:523: error: ‘analogRead’ was not declared in this scope

Hello, nanoquad.

The standalone Arduino library for our QTR sensors has not been updated to work with the Arduino 1.0 environment yet. I am working on releasing an official update, but for now, you should be able to use this updated version posted by Darth Maker.

- Kevin

That works. Many thanks.

I’d like to add that since you’re just trying to read a single QTR-1A you could probably just use analogRead to read it. Our library does have some nice features like calibration and multiple-sample averaging though.

–David

I down loaded the updated code written by Darth Marker and I’m still getting several errors. Could I get some assistance please. I’m trying to connect, calibrate, test and operate my QTR-8 for a line tracking robot.

sketch_mar23a.ino:35:30: error: PololuQTRSensors.h: No such file or directory
sketch_mar23a:46: error: ‘PololuQTRSensors’ has not been declared
sketch_mar23a.ino: In function ‘void init(unsigned char*, unsigned char, unsigned char, unsigned char)’:
sketch_mar23a:49: error: ‘calibratedMinimumOn’ was not declared in this scope
sketch_mar23a:50: error: ‘calibratedMaximumOn’ was not declared in this scope
sketch_mar23a:51: error: ‘calibratedMinimumOff’ was not declared in this scope
sketch_mar23a:52: error: ‘calibratedMaximumOff’ was not declared in this scope
sketch_mar23a:54: error: ‘QTR_MAX_SENSORS’ was not declared in this scope
sketch_mar23a:55: error: ‘_numSensors’ was not declared in this scope
sketch_mar23a:57: error: ‘_numSensors’ was not declared in this scope
sketch_mar23a:59: error: ‘_pins’ was not declared in this scope
sketch_mar23a:61: error: ‘_numSensors’ was not declared in this scope
sketch_mar23a:67: error: ‘_numSensors’ was not declared in this scope
sketch_mar23a:69: error: ‘_pins’ was not declared in this scope
sketch_mar23a:72: error: ‘_emitterPin’ was not declared in this scope
sketch_mar23a:73: error: ‘_type’ was not declared in this scope
sketch_mar23a.ino: At global scope:
sketch_mar23a:85: error: ‘PololuQTRSensors’ has not been declared
sketch_mar23a.ino: In function ‘void read(unsigned int*, unsigned char)’:
sketch_mar23a:87: error: ‘QTR_MAX_SENSORS’ was not declared in this scope
sketch_mar23a:90: error: ‘QTR_EMITTERS_ON’ was not declared in this scope
sketch_mar23a:90: error: ‘QTR_EMITTERS_ON_AND_OFF’ was not declared in this scope
sketch_mar23a:91: error: ‘emittersOn’ was not declared in this scope
sketch_mar23a:93: error: ‘_type’ was not declared in this scope
sketch_mar23a:95: error: ‘PololuQTRSensorsRC’ was not declared in this scope
sketch_mar23a:95: error: expected primary-expression before ‘)’ token
sketch_mar23a:95: error: expected )' before 'this' sketch_mar23a:96: error: 'emittersOff' was not declared in this scope sketch_mar23a:97: error: 'QTR_EMITTERS_ON_AND_OFF' was not declared in this scope sketch_mar23a:98: error: expected primary-expression before ')' token sketch_mar23a:98: error: expected)’ before ‘this’
sketch_mar23a:102: error: ‘PololuQTRSensorsAnalog’ was not declared in this scope
sketch_mar23a:102: error: expected primary-expression before ‘)’ token
sketch_mar23a:102: error: expected )' before 'this' sketch_mar23a:103: error: 'emittersOff' was not declared in this scope sketch_mar23a:104: error: 'QTR_EMITTERS_ON_AND_OFF' was not declared in this scope sketch_mar23a:105: error: expected primary-expression before ')' token sketch_mar23a:105: error: expected)’ before 'this’
sketch_mar23a:108: error: ‘QTR_EMITTERS_ON_AND_OFF’ was not declared in this scope
sketch_mar23a:110: error: ‘_numSensors’ was not declared in this scope
sketch_mar23a:112: error: ‘_maxValue’ was not declared in this scope
sketch_mar23a:112: error: ‘off_values’ was not declared in this scope
sketch_mar23a.ino: At global scope:
sketch_mar23a:122: error: ‘PololuQTRSensors’ has not been declared
sketch_mar23a.ino: In function ‘void emittersOff()’:
sketch_mar23a:124: error: ‘_emitterPin’ was not declared in this scope
sketch_mar23a:124: error: ‘QTR_NO_EMITTER_PIN’ was not declared in this scope
sketch_mar23a:126: error: ‘_emitterPin’ was not declared in this scope
sketch_mar23a.ino: At global scope:
sketch_mar23a:130: error: ‘PololuQTRSensors’ has not been declared
sketch_mar23a.ino: In function ‘void emittersOn()’:
sketch_mar23a:132: error: ‘_emitterPin’ was not declared in this scope
sketch_mar23a:132: error: ‘QTR_NO_EMITTER_PIN’ was not declared in this scope
sketch_mar23a:134: error: ‘_emitterPin’ was not declared in this scope
sketch_mar23a.ino: At global scope:
sketch_mar23a:139: error: ‘PololuQTRSensors’ has not been declared
sketch_mar23a.ino: In function ‘void resetCalibration()’:
sketch_mar23a:142: error: ‘_numSensors’ was not declared in this scope
sketch_mar23a:144: error: ‘calibratedMinimumOn’ was not declared in this scope
sketch_mar23a:145: error: ‘_maxValue’ was not declared in this scope
sketch_mar23a:146: error: ‘calibratedMinimumOff’ was not declared in this scope
sketch_mar23a:147: error: ‘_maxValue’ was not declared in this scope
sketch_mar23a:148: error: ‘calibratedMaximumOn’ was not declared in this scope
sketch_mar23a:150: error: ‘calibratedMaximumOff’ was not declared in this scope
sketch_mar23a.ino: At global scope:
sketch_mar23a:159: error: ‘PololuQTRSensors’ has not been declared
sketch_mar23a.ino: In function ‘void calibrate(unsigned char)’:
sketch_mar23a:161: error: ‘QTR_EMITTERS_ON_AND_OFF’ was not declared in this scope
sketch_mar23a:161: error: ‘QTR_EMITTERS_ON’ was not declared in this scope
sketch_mar23a:163: error: ‘calibratedMinimumOn’ was not declared in this scope
sketch_mar23a:164: error: ‘calibratedMaximumOn’ was not declared in this scope
sketch_mar23a:165: error: ‘calibrateOnOrOff’ was not declared in this scope
sketch_mar23a:169: error: ‘QTR_EMITTERS_ON_AND_OFF’ was not declared in this scope
sketch_mar23a:169: error: ‘QTR_EMITTERS_OFF’ was not declared in this scope
sketch_mar23a:171: error: ‘calibratedMinimumOff’ was not declared in this scope
sketch_mar23a:172: error: ‘calibratedMaximumOff’ was not declared in this scope
sketch_mar23a:173: error: ‘calibrateOnOrOff’ was not declared in this scope
sketch_mar23a.ino: At global scope:
sketch_mar23a:177: error: ‘PololuQTRSensors’ has not been declared
sketch_mar23a.ino: In function ‘void calibrateOnOrOff(unsigned int**, unsigned int**, unsigned char)’:
sketch_mar23a:189: error: ‘_numSensors’ was not declared in this scope
sketch_mar23a:203: error: ‘_numSensors’ was not declared in this scope
sketch_mar23a:210: error: ‘_maxValue’ was not declared in this scope
sketch_mar23a:217: error: ‘_numSensors’ was not declared in this scope
sketch_mar23a:230: error: ‘_numSensors’ was not declared in this scope
sketch_mar23a.ino: At global scope:
sketch_mar23a:245: error: ‘PololuQTRSensors’ has not been declared
sketch_mar23a.ino: In function ‘void readCalibrated(unsigned int*, unsigned char)’:
sketch_mar23a:250: error: ‘QTR_EMITTERS_ON_AND_OFF’ was not declared in this scope
sketch_mar23a:250: error: ‘QTR_EMITTERS_OFF’ was not declared in this scope
sketch_mar23a:251: error: ‘calibratedMinimumOff’ was not declared in this scope
sketch_mar23a:251: error: ‘calibratedMaximumOff’ was not declared in this scope
sketch_mar23a:253: error: ‘QTR_EMITTERS_ON_AND_OFF’ was not declared in this scope
sketch_mar23a:253: error: ‘QTR_EMITTERS_ON’ was not declared in this scope
sketch_mar23a:254: error: ‘calibratedMinimumOn’ was not declared in this scope
sketch_mar23a:254: error: ‘calibratedMaximumOn’ was not declared in this scope
sketch_mar23a:260: error: ‘_numSensors’ was not declared in this scope
sketch_mar23a:266: error: ‘QTR_EMITTERS_ON’ was not declared in this scope
sketch_mar23a:268: error: ‘calibratedMaximumOn’ was not declared in this scope
sketch_mar23a:269: error: ‘calibratedMinimumOn’ was not declared in this scope
sketch_mar23a:271: error: ‘QTR_EMITTERS_OFF’ was not declared in this scope
sketch_mar23a:273: error: ‘calibratedMaximumOff’ was not declared in this scope
sketch_mar23a:274: error: ‘calibratedMinimumOff’ was not declared in this scope
sketch_mar23a:279: error: ‘calibratedMinimumOff’ was not declared in this scope
sketch_mar23a:279: error: ‘calibratedMinimumOn’ was not declared in this scope
sketch_mar23a:280: error: ‘_maxValue’ was not declared in this scope
sketch_mar23a:282: error: ‘_maxValue’ was not declared in this scope
sketch_mar23a:284: error: ‘calibratedMaximumOff’ was not declared in this scope
sketch_mar23a:284: error: ‘calibratedMaximumOn’ was not declared in this scope
sketch_mar23a:285: error: ‘_maxValue’ was not declared in this scope
sketch_mar23a:287: error: ‘_maxValue’ was not declared in this scope
sketch_mar23a.ino: At global scope:
sketch_mar23a:325: error: ‘PololuQTRSensors’ has not been declared
sketch_mar23a.ino: In function ‘int readLine(unsigned int*, unsigned char, unsigned char)’:
sketch_mar23a:339: error: ‘_numSensors’ was not declared in this scope
sketch_mar23a:359: error: ‘_numSensors’ was not declared in this scope
sketch_mar23a.ino: At global scope:
sketch_mar23a:376: error: ‘PololuQTRSensorsRC’ has not been declared
sketch_mar23a:377: error: ISO C++ forbids declaration of ‘PololuQTRSensorsRC’ with no type
sketch_mar23a.ino: In function ‘int PololuQTRSensorsRC(unsigned char*, unsigned char, unsigned int, unsigned char)’:
sketch_mar23a:379: error: ‘_pins’ was not declared in this scope
sketch_mar23a.ino: At global scope:
sketch_mar23a:404: error: ‘PololuQTRSensorsRC’ is not a class or namespace
sketch_mar23a.ino: In function ‘void init(unsigned char*, unsigned char, unsigned int, unsigned char)’:
sketch_mar23a:407: error: ‘PololuQTRSensors’ has not been declared
sketch_mar23a:409: error: ‘_maxValue’ was not declared in this scope
sketch_mar23a.ino: At global scope:
sketch_mar23a:421: error: ‘PololuQTRSensorsRC’ is not a class or namespace
sketch_mar23a.ino: In function ‘void readPrivate(unsigned int*)’:
sketch_mar23a:425: error: ‘_pins’ was not declared in this scope
sketch_mar23a:428: error: ‘_numSensors’ was not declared in this scope
sketch_mar23a:430: error: ‘_maxValue’ was not declared in this scope
sketch_mar23a:431: error: ‘_pins’ was not declared in this scope
sketch_mar23a:437: error: ‘_numSensors’ was not declared in this scope
sketch_mar23a:439: error: ‘_pins’ was not declared in this scope
sketch_mar23a:444: error: ‘_maxValue’ was not declared in this scope
sketch_mar23a:447: error: ‘_numSensors’ was not declared in this scope
sketch_mar23a:449: error: ‘_pins’ was not declared in this scope
sketch_mar23a.ino: At global scope:
sketch_mar23a:458: error: ‘PololuQTRSensorsAnalog’ has not been declared
sketch_mar23a:460: error: ISO C++ forbids declaration of ‘PololuQTRSensorsAnalog’ with no type
sketch_mar23a.ino: In function ‘int PololuQTRSensorsAnalog(unsigned char*, unsigned char, unsigned char, unsigned char)’:
sketch_mar23a:462: error: ‘_pins’ was not declared in this scope
sketch_mar23a.ino: At global scope:
sketch_mar23a:490: error: ‘PololuQTRSensorsAnalog’ is not a class or namespace
sketch_mar23a.ino: In function ‘void init(unsigned char*, unsigned char, unsigned char, unsigned char)’:
sketch_mar23a:492: error: redefinition of 'void init(unsigned char*, unsigned char, unsigned char, unsigned char)'
sketch_mar23a:47: error: ‘void init(unsigned char*, unsigned char, unsigned char, unsigned char)’ previously defined here
sketch_mar23a:494: error: ‘PololuQTRSensors’ has not been declared
sketch_mar23a:496: error: ‘_numSamplesPerSensor’ was not declared in this scope
sketch_mar23a:497: error: ‘_maxValue’ was not declared in this scope
sketch_mar23a.ino: At global scope:
sketch_mar23a:509: error: ‘PololuQTRSensorsAnalog’ is not a class or namespace
sketch_mar23a.ino: In function ‘void readPrivate(unsigned int*)’:
sketch_mar23a:509: error: redefinition of 'void readPrivate(unsigned int*)'
sketch_mar23a:421: error: ‘void readPrivate(unsigned int*)’ previously defined here
sketch_mar23a:513: error: ‘_pins’ was not declared in this scope
sketch_mar23a:517: error: ‘_numSensors’ was not declared in this scope
sketch_mar23a:520: error: ‘_numSamplesPerSensor’ was not declared in this scope
sketch_mar23a:522: error: ‘_numSensors’ was not declared in this scope
sketch_mar23a:524: error: ‘_pins’ was not declared in this scope
sketch_mar23a:529: error: ‘_numSensors’ was not declared in this scope
sketch_mar23a:530: error: ‘_numSamplesPerSensor’ was not declared in this scope
sketch_mar23a.ino: At global scope:
sketch_mar23a:535: error: expected constructor, destructor, or type conversion before ‘::’ token

Hello. This thread is a year old and we have already updated our Arduino Library for the Pololu QTR Reflectance Sensors to work with Arduino 1.0, so instead of using Darth Maker’s version I recommend that you use our version by following that link.

In general, you should pay special attention to the first error that the compile givers you:

sketch_mar23a.ino:35:30: error: PololuQTRSensors.h: No such file or directory

This error indicates that you did not put the library files in the correct place. Could you describe where you installed the library? Please include some screenshots showing the library files in their installed location and the other files nearby. Also, you should try restarting the Arduino IDE because it only detects new libraries at startup.

–David