Pipeline Technology Centre / Mbed 2 deprecated ConsolTest

Dependencies:   mbed

Dependents:   TabbedGUIMbed

Distance.cpp

Committer:
aidanPJG
Date:
2015-07-07
Revision:
25:bab86a12e9ad
Parent:
24:92600b1d15b1
Child:
27:f3ca0269515f

File content as of revision 25:bab86a12e9ad:

#include "mbed.h"

extern Serial pc;

float radius;
float distance;

float Distance(){
        pc.printf("Ready to Read\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;
                    break;
                    }
            }
        pc.printf("and distance has be calulated\n"); 
        return(distance);//returns the distance in as a float 
}