---

Dependencies:   mbed

Fork of MicroMouse_MASTER_FIVE by PES2_R2D2.0

Revision:
1:d9e840c48b1e
Parent:
0:a9fe4ef404bf
Child:
9:ab19796bf14a
--- a/IRSensor.cpp	Wed Mar 07 14:06:19 2018 +0000
+++ b/IRSensor.cpp	Sat Mar 31 16:45:57 2018 +0000
@@ -3,23 +3,20 @@
 
 using namespace std;
 
-IRSensor::IRSensor(AnalogIn& distance, DigitalOut& bit0, DigitalOut& bit1, DigitalOut& bit2, int number) :
-    distance(distance), bit0(bit0), bit1(bit1), bit2(bit2)
-{
-    this->number = number;
-}
+
+IRSensor::IRSensor(AnalogIn& distance) :
+    distance(distance)
+{}
 
 IRSensor::~IRSensor() {}
 
 float IRSensor::read()
 {
-
-    bit0 = (number >> 0) & 1;
-    bit1 = (number >> 1) & 1;
-    bit2 = (number >> 2) & 1;
-
-    float d = -0.58f*sqrt(distance)+0.58f; // Lesen der Distanz in [m]
-
-    return d;
-
+    double d = distance * 3.3f; // Change the value to be in the 0 to 3300 range
+    
+    //DONT TOUCH
+    //y = 14.098x6 - 147.35x5 + 627.68x4 - 1403.5x3 + 1765.1x2 - 1236.9x + 430.44 POLYNOMFUNKTION AUS EXCEL
+    float f = 14.098f*((d)*(d)*(d)*(d)*(d)*(d)) - 147.35f*((d)*(d)*(d)*(d)*(d)) + 627.68*((d)*(d)*(d)*(d)) - 1403.5f*((d)*(d)*(d)) + 1765.1f*((d)*(d)) - 1236.9f*(d) + 430.44f; // Lesen der Distanz in [mm]  
+    
+    return f;
 }
\ No newline at end of file