READY TO RUMBLE

Dependencies:   mbed

Fork of Micromouse_alpha_copy_copy by PES2_R2D2.0

Revision:
0:a9fe4ef404bf
Child:
1:d9e840c48b1e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/IRSensor.cpp	Wed Mar 07 14:06:19 2018 +0000
@@ -0,0 +1,25 @@
+#include <cmath>
+#include "IRSensor.h"
+
+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() {}
+
+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;
+
+}
\ No newline at end of file