Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
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
}