![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
02/07/15
Dependencies: mbed
UserInput.cpp@56:bf08d9e50ccc, 2015-07-28 (annotated)
- Committer:
- aidanPJG
- Date:
- Tue Jul 28 14:40:26 2015 +0000
- Revision:
- 56:bf08d9e50ccc
- Parent:
- 54:9322b1b76e13
- Child:
- 59:2cbbd6fea55b
Quite messy but time working more accurately
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aidanPJG | 48:e9578f56534a | 1 | #include "mbed.h" |
aidanPJG | 54:9322b1b76e13 | 2 | #include <utility> |
aidanPJG | 56:bf08d9e50ccc | 3 | #include <string> |
aidanPJG | 48:e9578f56534a | 4 | |
aidanPJG | 48:e9578f56534a | 5 | extern Serial pc; |
aidanPJG | 48:e9578f56534a | 6 | int sensorNumber; |
aidanPJG | 49:889751dd0395 | 7 | double sensorDistance; |
aidanPJG | 48:e9578f56534a | 8 | |
aidanPJG | 56:bf08d9e50ccc | 9 | int inputNoOfPins() |
aidanPJG | 56:bf08d9e50ccc | 10 | { |
aidanPJG | 48:e9578f56534a | 11 | pc.printf("Ready to Read.\n"); |
aidanPJG | 48:e9578f56534a | 12 | pc.printf("Enter the number of sensors\n"); |
aidanPJG | 48:e9578f56534a | 13 | while (1){ |
aidanPJG | 48:e9578f56534a | 14 | if (pc.readable()) |
aidanPJG | 48:e9578f56534a | 15 | { |
aidanPJG | 48:e9578f56534a | 16 | pc.scanf("%d", &sensorNumber); |
aidanPJG | 54:9322b1b76e13 | 17 | break; |
aidanPJG | 54:9322b1b76e13 | 18 | } |
aidanPJG | 56:bf08d9e50ccc | 19 | } |
aidanPJG | 54:9322b1b76e13 | 20 | pc.printf("sensorNumber : %d \t " ,sensorNumber ); |
aidanPJG | 54:9322b1b76e13 | 21 | return(sensorNumber); |
aidanPJG | 56:bf08d9e50ccc | 22 | } |
aidanPJG | 54:9322b1b76e13 | 23 | double inputDistance(){ |
aidanPJG | 54:9322b1b76e13 | 24 | pc.printf("Enter the distance between each sensor\n "); |
aidanPJG | 54:9322b1b76e13 | 25 | while (1){ |
aidanPJG | 54:9322b1b76e13 | 26 | if (pc.readable()) |
aidanPJG | 54:9322b1b76e13 | 27 | { |
aidanPJG | 49:889751dd0395 | 28 | pc.scanf("%lf", &sensorDistance); //has to &lf because must know the size of it before getting it in |
aidanPJG | 48:e9578f56534a | 29 | break; |
aidanPJG | 48:e9578f56534a | 30 | } |
aidanPJG | 48:e9578f56534a | 31 | } |
aidanPJG | 54:9322b1b76e13 | 32 | pc.printf( "SensorDistance : %f", sensorDistance ); |
aidanPJG | 54:9322b1b76e13 | 33 | return(sensorDistance); |
aidanPJG | 54:9322b1b76e13 | 34 | } |