Pipeline Technology Centre / Mbed 2 deprecated ConsolTest

Dependencies:   mbed

Dependents:   TabbedGUIMbed

Distance.cpp

Committer:
ADAMSTRUTT
Date:
2015-07-07
Revision:
27:f3ca0269515f
Parent:
25:bab86a12e9ad
Child:
36:a2d20d5e5e19

File content as of revision 27:f3ca0269515f:

#include "mbed.h"

extern Serial pc;

float radius;
int number_sensors;
float distance;

float Distance(){
        pc.printf("Ready to Read.\n Enter the Radius\n");
        while (1){
                if (pc.readable()){
                    pc.scanf("%f", &radius);//resives the radius from the PC
                    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("The distance has be calulated and is "); 
        return(distance);//returns the distance in as a float 
}