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:
- 20:0b2279011691
- Parent:
- 17:d9fb4a3780c7
- Child:
- 24:92600b1d15b1
--- a/Distance.cpp Tue Jul 07 08:47:35 2015 +0000
+++ b/Distance.cpp Tue Jul 07 12:37:34 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