Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of TestRegler by
Diff: IRSensor.cpp
- Revision:
- 4:767fd282dd9c
- Parent:
- 0:6d0671ae4648
- Child:
- 5:e715d157ced5
--- a/IRSensor.cpp Mon Apr 23 12:19:12 2018 +0000
+++ b/IRSensor.cpp Tue Apr 24 18:16:05 2018 +0000
@@ -26,14 +26,27 @@
const int IRSensor :: minIrR = 100; //Noch definieren
const int IRSensor :: minIrL = 100;
const int IRSensor :: minIrF = 100;
+ const float IRSensor :: Period = 0.2;
+
+
// IR Sensor Distanz in mm
-IRSensor::IRSensor(AnalogIn& IrRight, AnalogIn& IrLeft, AnalogIn& IrFront, float dis2R, float dis2L, float dis2F) :
-IrRight(IrRight), IrLeft(IrLeft), IrFront(IrFront), dis2R(dis2R), dis2L(dis2L), dis2F(dis2F){}
+IRSensor::IRSensor(AnalogIn& IrRight, AnalogIn& IrLeft, AnalogIn& IrFront, float dis2R, float dis2L, float dis2F, AnalogIn& LineSensor) :
+IrRight(IrRight), IrLeft(IrLeft), IrFront(IrFront), dis2R(dis2R), dis2L(dis2L), dis2F(dis2F), LineSensor(LineSensor){
+ ticker.attach(callback(this, &IRSensor::codeB), Period);
+ this-> ende = ende;
+ ende = 0;
+ }
+
+
-IRSensor::~IRSensor(){}
+IRSensor::~IRSensor(){
+ ticker.detach();
+ }
+
+
float IRSensor::readR() {
@@ -84,5 +97,27 @@
if(disF < minIrR) {
IrF = 1;
} else { IrF = 0; }
- return IrF;
-}
\ No newline at end of file
+ return ende;//IrF;
+}
+
+void IRSensor :: codeB() {
+
+ double line = LineSensor.read();
+ if (line >0.3){ //Line Sensor
+ finish = 1;
+ }else{ finish = 0;
+}
+ if (finish != finishLast){
+ ende = 1;
+}
+ if (line == 1) {
+ ende = 1;
+}
+ finishLast = finish;
+ //printf("Line Sensor ist %d\n",ende);
+ return;
+}
+
+int IRSensor::get_ende(){
+ return ende;
+ }
\ No newline at end of file
