Pipeline Technology Centre / Mbed 2 deprecated ConsolTest

Dependencies:   mbed

Dependents:   TabbedGUIMbed

Committer:
aidanPJG
Date:
Tue Jul 07 14:12:51 2015 +0000
Revision:
25:bab86a12e9ad
Parent:
24:92600b1d15b1
Child:
27:f3ca0269515f
Calculate able to tell when the beam is broken and print it

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ADAMSTRUTT 17:d9fb4a3780c7 1 #include "mbed.h"
ADAMSTRUTT 15:a468af6ba5a4 2
aidanPJG 25:bab86a12e9ad 3 extern Serial pc;
ADAMSTRUTT 20:0b2279011691 4
ADAMSTRUTT 20:0b2279011691 5 float radius;
ADAMSTRUTT 20:0b2279011691 6 float distance;
ADAMSTRUTT 15:a468af6ba5a4 7
ADAMSTRUTT 15:a468af6ba5a4 8 float Distance(){
ADAMSTRUTT 20:0b2279011691 9 pc.printf("Ready to Read\n");
ADAMSTRUTT 15:a468af6ba5a4 10 while (1){
ADAMSTRUTT 20:0b2279011691 11 if (pc.readable()){
ADAMSTRUTT 20:0b2279011691 12 pc.printf("Radius has been resived ");
ADAMSTRUTT 20:0b2279011691 13 pc.scanf("%f", &radius);//resives the radius from the PC
ADAMSTRUTT 20:0b2279011691 14 distance = radius+2;
ADAMSTRUTT 20:0b2279011691 15 break;
ADAMSTRUTT 20:0b2279011691 16 }
ADAMSTRUTT 15:a468af6ba5a4 17 }
ADAMSTRUTT 20:0b2279011691 18 pc.printf("and distance has be calulated\n");
ADAMSTRUTT 20:0b2279011691 19 return(distance);//returns the distance in as a float
ADAMSTRUTT 20:0b2279011691 20 }