Pipeline Technology Centre / Mbed 2 deprecated ConsolTest

Dependencies:   mbed

Dependents:   TabbedGUIMbed

Revision:
27:f3ca0269515f
Parent:
25:bab86a12e9ad
Child:
36:a2d20d5e5e19
diff -r bab86a12e9ad -r f3ca0269515f Distance.cpp
--- a/Distance.cpp	Tue Jul 07 14:12:51 2015 +0000
+++ b/Distance.cpp	Tue Jul 07 14:54:08 2015 +0000
@@ -3,18 +3,22 @@
 extern Serial pc;
 
 float radius;
+int number_sensors;
 float distance;
 
 float Distance(){
-        pc.printf("Ready to Read\n");
+        pc.printf("Ready to Read.\n Enter the Radius\n");
         while (1){
                 if (pc.readable()){
-                    pc.printf("Radius has been resived ");
                     pc.scanf("%f", &radius);//resives the radius from the PC
-                    distance = radius+2;
+                    pc.printf("The Radius has been resived\n ");
+                    pc.printf("Enter the number of sensors\n");
+                    pc.scanf("%d", &number_sensors);
+                    pc.printf("The number of sensors have been resived\n ");
+                    distance = (2*radius*3.14159)/number_sensors;
                     break;
                     }
             }
-        pc.printf("and distance has be calulated\n"); 
+        pc.printf("The distance has be calulated and is "); 
         return(distance);//returns the distance in as a float 
 }
\ No newline at end of file