Do NOT modify!

Dependencies:   mbed Servo ServoArm

Fork of PES_Yanick by zhaw_st16b_pes2_10

Revision:
12:c0bcb95885dd
Parent:
10:f76476943a6c
--- a/Sources/Farbsensor.cpp	Sat May 06 13:33:23 2017 +0000
+++ b/Sources/Farbsensor.cpp	Wed May 10 13:30:13 2017 +0000
@@ -18,28 +18,31 @@
 
 int Farbsensor::read()
 {
-    int farbe;
-    float Messungen=0.0;
-    for(int i=0;i<10;i++){
-        Messungen+=FarbVoltage->read();
-        wait(0.2);
-        }  
-    float Ufarbsensor = Messungen/10.0;
-    Ufarbsensor = Ufarbsensor*3300; //Set the Voltage between 0mV und 3300mV
-
-    if ((Ufarbsensor > GREEN_DOWNLIMIT) && (Ufarbsensor < GREEN_UPLIMIT))
-        {
-         farbe=1;
+    static int time=0;
+    static float Messungen=0.0f;
+    if( time < 10 ){
+        Messungen += FarbVoltage->read();
+        time++;
+        return -1;
+    }
+    else{
+        time = 0;
+        float Ufarbsensor = Messungen/10.0;
+        Ufarbsensor = Ufarbsensor*3300; //Set the Voltage between 0mV und 3300mV
+    
+        if ((Ufarbsensor > GREEN_DOWNLIMIT) && (Ufarbsensor < GREEN_UPLIMIT))
+            {
+             return GREEN;
+            }
+        else if(Ufarbsensor < RED_UPLIMIT)
+            {
+             return RED;
+            }
+        else 
+            {
+             return NOBLOCK;
+            }
         }
-    else if(Ufarbsensor < RED_UPLIMIT)
-        {
-         farbe=-1;
-        }
-    else 
-        {
-         farbe=0;
-        }
-    return farbe;
 }
 
 Farbsensor::operator int()