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
Diff: Distance.cpp
- Revision:
- 24:92600b1d15b1
- Parent:
- 21:5256c5435b33
- Parent:
- 20:0b2279011691
- Child:
- 25:bab86a12e9ad
diff -r 6c2416d81825 -r 92600b1d15b1 Distance.cpp
--- a/Distance.cpp Tue Jul 07 12:49:02 2015 +0000
+++ b/Distance.cpp Tue Jul 07 12:56:24 2015 +0000
@@ -1,17 +1,20 @@
#include "mbed.h"
-int radius;
-float number_sensors;
+Serial pc(USBTX, USBRX);//tx, rx
+
+float radius;
+float distance;
float Distance(){
- {
-
- pc.prinf('Ready to read\n');
+ pc.printf("Ready to Read\n");
while (1){
- if (pc.readable()){
- radius = pc.read();
- number_sensors()= pc.read();
- break;
- }
+ if (pc.readable()){
+ pc.printf("Radius has been resived ");
+ pc.scanf("%f", &radius);//resives the radius from the PC
+ distance = radius+2;
+ break;
+ }
}
- }
\ No newline at end of file
+ pc.printf("and distance has be calulated\n");
+ return(distance);//returns the distance in as a float
+}
\ No newline at end of file