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@27:f3ca0269515f, 2015-07-07 (annotated)
- Committer:
- ADAMSTRUTT
- Date:
- Tue Jul 07 14:54:08 2015 +0000
- Revision:
- 27:f3ca0269515f
- Parent:
- 25:bab86a12e9ad
- Child:
- 36:a2d20d5e5e19
End of day
Who changed what in which revision?
| User | Revision | Line number | New 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 | 20:0b2279011691 | 7 | float distance; |
| ADAMSTRUTT | 15:a468af6ba5a4 | 8 | |
| ADAMSTRUTT | 15:a468af6ba5a4 | 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 | 27:f3ca0269515f | 18 | distance = (2*radius*3.14159)/number_sensors; |
| ADAMSTRUTT | 20:0b2279011691 | 19 | break; |
| ADAMSTRUTT | 20:0b2279011691 | 20 | } |
| ADAMSTRUTT | 15:a468af6ba5a4 | 21 | } |
| ADAMSTRUTT | 27:f3ca0269515f | 22 | pc.printf("The distance has be calulated and is "); |
| ADAMSTRUTT | 20:0b2279011691 | 23 | return(distance);//returns the distance in as a float |
| ADAMSTRUTT | 20:0b2279011691 | 24 | } |