Pipeline Technology Centre / Mbed 2 deprecated ConsolTest

Dependencies:   mbed

Dependents:   TabbedGUIMbed

Committer:
ADAMSTRUTT
Date:
Wed Jul 08 10:48:12 2015 +0000
Revision:
40:23008d8111d5
Parent:
36:a2d20d5e5e19
Before lunch Wednesday

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 27:f3ca0269515f 6 int number_sensors;
ADAMSTRUTT 36:a2d20d5e5e19 7 float distance_out;
ADAMSTRUTT 15:a468af6ba5a4 8
ADAMSTRUTT 36:a2d20d5e5e19 9 float distance(){
ADAMSTRUTT 27:f3ca0269515f 10 pc.printf("Ready to Read.\n Enter the Radius\n");
ADAMSTRUTT 15:a468af6ba5a4 11 while (1){
ADAMSTRUTT 20:0b2279011691 12 if (pc.readable()){
ADAMSTRUTT 20:0b2279011691 13 pc.scanf("%f", &radius);//resives the radius from the PC
ADAMSTRUTT 27:f3ca0269515f 14 pc.printf("The Radius has been resived\n ");
ADAMSTRUTT 27:f3ca0269515f 15 pc.printf("Enter the number of sensors\n");
ADAMSTRUTT 27:f3ca0269515f 16 pc.scanf("%d", &number_sensors);
ADAMSTRUTT 27:f3ca0269515f 17 pc.printf("The number of sensors have been resived\n ");
ADAMSTRUTT 36:a2d20d5e5e19 18 distance_out = (2*radius*3.14159)/number_sensors;
ADAMSTRUTT 20:0b2279011691 19 break;
ADAMSTRUTT 20:0b2279011691 20 }
ADAMSTRUTT 15:a468af6ba5a4 21 }
ADAMSTRUTT 40:23008d8111d5 22 pc.printf("The distance has be calulated and is %f", distance_out);
ADAMSTRUTT 36:a2d20d5e5e19 23 return(distance_out);//returns the distance in as a float
ADAMSTRUTT 20:0b2279011691 24 }