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 Roboshark_V9 by
Diff: IRSensor.cpp
- Revision:
- 6:7bbcdd07bc2d
- Parent:
- 5:e715d157ced5
- Child:
- 7:862d80e0ea2d
--- a/IRSensor.cpp Thu Apr 26 05:58:07 2018 +0000 +++ b/IRSensor.cpp Thu May 03 19:36:16 2018 +0000 @@ -1,7 +1,11 @@ +/*Roboshark V4 +IRSensor.cpp +Erstellt: V. Ahlers +geändert: V.Ahlers +V.5.18 +Einlesen und Codieren der IR Sensoren +*/ -//Implementation IR Sensoren -// V04.18 -// V. Ahlers #include <cmath> #include "IRSensor.h" @@ -23,16 +27,16 @@ const float IRSensor :: PF3 = 0.0024f; const float IRSensor :: PF4 = -1.3299f; const float IRSensor :: PF5 = 351.1557f; - const int IRSensor :: minIrR = 100; //Noch definieren + const int IRSensor :: minIrR = 100; // minimal Distanzen const int IRSensor :: minIrL = 100; const int IRSensor :: minIrF = 100; - const float IRSensor :: Period = 0.2; + const float IRSensor :: Period = 0.2; // Ticker Periode -// IR Sensor Distanz in mm + 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); @@ -47,7 +51,7 @@ } - +// IR Sensor Distanz in mm float IRSensor::readR() { measR = IrRight.read(); // Converts and read the analog input value (value from 0.0 to 1.0) @@ -75,7 +79,7 @@ return disF; } -// IR Sensor Zusatand +// IR Sensor Zusatand codieren int IRSensor::codeR(){ if(disR < minIrR) { @@ -100,10 +104,11 @@ return IrF;//IrF; } +//Line Sensor void IRSensor :: codeB() { double line = LineSensor.read(); - if (line >0.3){ //Line Sensor + if (line >0.3){ finish = 1; }else{ finish = 0; }