在arduino中,此范围内未声明'QTR_NO_EMITTER_PIN'中的错误?

时间:2014-02-04 10:58:53

标签: arduino

这里是代码的一部分,我有问题,我添加了库,我包括它,它也出现在(草图 - >导入库)

#include <PololuQTRSensors.h>
    #include <Servo.h>

    // Change the values below to suit your robot's motors, weight, wheel type, etc.
    #define KP 0.5
    #define KD 1.7

#define M1_DEFAULT_SPEED 100
#define M2_DEFAULT_SPEED 100

#define rightMaxSpeed 200
#define leftMaxSpeed 200

#define NUM_SENSORS   6     // number of sensors used
#define TIMEOUT       2500  // waits for 2500 us for sensor outputs to go low

#define leftPWM   3    
#define rightPWM  5
//#define leftEnable 2
//#define rightEnable 4
//#define leftGND   2//12   //connected Directly to gnd 
//#define rightGND  4//13

#define echoPin 2 // Echo Pin
#define trigPin 4// Trigger Pin
#define LEDpin 13 //used for testing and calibration

#define DEBUG 0  
#define LINEFOLLOWER 0

Servo svoTilt;
Servo svoClaw;

/* Create instance of sensors. Sensors connected to pins 6 to 11
*/
PololuQTRSensorsRC qtrrc((unsigned char[]) {6,7,8,9,10,11},  NUM_SENSORS, TIMEOUT, QTR_NO_EMITTER_PIN); 

但我在'QTR_NO_EMITTER_PIN'中有以下错误未在此范围内声明,

我不知道为什么。

1 个答案:

答案 0 :(得分:1)

您需要在草图中包含以下内容

#include <QTRSensors.h>

之后

#include <PololuQTRSensors.h>
#include <Servo.h>

下载库后,我能够成功编译以下内容。

#include <PololuQTRSensors.h>
#include <QTRSensors.h>
#include <Servo.h>
#define NUM_SENSORS   6     // number of sensors used
#define TIMEOUT       2500  // waits for 2500 us for sensor outputs to go low
#define DEBUG 0  
#define LINEFOLLOWER 0

Servo svoTilt;
Servo svoClaw;

QTRSensorsRC qtrrc((unsigned char[]) {6,7,8,9,10,11},  NUM_SENSORS, TIMEOUT, QTR_NO_EMITTER_PIN); 

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
}

以下成功结果。

C:\Users\mflaga\AppData\Local\Temp\build5914291637870389663.tmp/QTR_NO_EMITTER_PIN.cpp.hex 

Sketch uses 2,264 bytes (7%) of program storage space. Maximum is 32,256 bytes.
Global variables use 84 bytes (4%) of dynamic memory, leaving 1,964 bytes for local variables. Maximum is 2,048 bytes.

当我注释掉“#include”

时,我得到与上述相同的错误

请注意,您可能需要重新启动IDE。让它缓存库文件的存在。