Scu*_*Kay 5 c c++ class arduino
对于学校我正在建造一个机器人,需要能够使用3个QRE1113 linesensors检测线路.(http://www.sparkfun.com/products/9454)我创建了4个库,两个用于驱动(Motor()和Driver())它们工作正常.现在我创建了Linesensor和Eye库,这些都造成了一些麻烦.当我想使用这些库时,setup()函数不会执行小队.甚至没有打开LED.什么似乎是问题?
主文件:
#include "Motor.h"
#include "Driver.h"
#include "Lichtsensor.h"
#include "Eye.h"
Motor motor1(5, 4, true);
Motor motor2(6, 7, false);
Driver driver(motor1, motor2);
Eye eye1;
void setup(){
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
Serial.begin(9600);
Serial.println("#################################################");
Serial.println("# This sketch communicates with the arduino and #");
Serial.println("# makes the robot drive, and react to a sensor. #");
Serial.println("#################################################\n");
}
void loop(){
if (eye1.getDikkeLijn() == true) {
Serial.println("Lijn");
}
else {
Serial.println("Niks");
}
delay(1000);
}
Run Code Online (Sandbox Code Playgroud)
眼库:
/*
Controls Lichtsensors
*/
#ifndef Eye_h
#define Eye_h
#include "Arduino.h"
#include "Lichtsensor.h"
class Eye
public:
Eye();
Eye(Lichtsensor l1, Lichtsensor l2, Lichtsensor l3);
boolean getDikkeLijn();
boolean getDunneLijn();
private:
Lichtsensor _l1;
Lichtsensor _l2;
Lichtsensor _l3;
};
#endif
Run Code Online (Sandbox Code Playgroud)
和linesensor:
/*
Library to get values from a light sensor
*/
#ifndef Lichtsensor_h
#define Lichtsensor_h
#include "Arduino.h"
class Lichtsensor {
public:
Lichtsensor();
Lichtsensor(int analogPin);
int getCalibreerWaarde();
int getLichtWaarde();
boolean isDonker();
private:
int _lichtCalibreerWaarde;
int _analogPin;
};
#endif
Run Code Online (Sandbox Code Playgroud)