Grundfunktionen für Micromouse

Dependencies:   AutomationElements mbed

Revision:
1:4808f55970e8
Parent:
0:e38b500d6e74
--- a/ReadSensor.cpp	Thu Apr 19 11:31:49 2018 +0000
+++ b/ReadSensor.cpp	Sun Apr 22 09:55:40 2018 +0000
@@ -14,11 +14,6 @@
 HCSR04 sensor_Front(EchoF, TriggerF);
 HCSR04 sensor_Right(EchoR, TriggerR);
 
-//PwmOut& pwmLeft
-
-//float sampleTime = 0.5f;
-//PT1 filter(1, 2, sampleTime);
-//Ticker ticker_sens;
 float distance;
 float filteredDistance;
 int Glob_Position;
@@ -43,7 +38,7 @@
     }
 }
 
-int ReadSensor(int Position)
+int readSensor(int Position)
 {
     Glob_Position = Position;
     //PT1 filter(1, 2, sampleTime);
@@ -95,7 +90,7 @@
     }
 }
 
-float ReadSensorValue(int Position)
+float readSensorValue(int Position)
 {
     Glob_Position = Position;
     float distancetot = 0;
@@ -105,7 +100,7 @@
     sensor_Front.setRanges(2,400);
     sensor_Right.setRanges(2, 400);
     while(true) {
-        for(i = 0; i < 3; i++) {
+        for(i = 0; i < 2; i++) {
             switch(Position) {
                 case 1:
                     while(!sensor_Left.isNewDataReady()) {
@@ -135,7 +130,8 @@
             distancetot = distancetot + distance;
         }
         //ticker_sens.detach();
-        distancetot = distancetot / i;
+        distancetot = distancetot / (i);
+        printf("%f\n",distancetot);
         return distancetot;
         //filter.in(distance);
         //filteredDistance = filter.out();