![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
02/07/15
Dependencies: mbed
Diff: UserInput.cpp
- Revision:
- 70:168d67695a65
- Parent:
- 59:2cbbd6fea55b
- Child:
- 71:60f06e7e50a3
diff -r 74bffa1d3f7f -r 168d67695a65 UserInput.cpp --- a/UserInput.cpp Thu Aug 27 14:32:20 2015 +0000 +++ b/UserInput.cpp Thu Sep 03 15:10:51 2015 +0000 @@ -5,30 +5,30 @@ extern Serial pc; int sensorNumber; double sensorDistance; +string date; -int inputNoOfPins() +int inputNoOfPins() //gets the number of pins on a former { - // pc.printf("Ready to Read.\n"); - // pc.printf("Enter the number of sensors\n"); - while (1){ - if (pc.readable()) + while (1) //keep doing this + { + if (pc.readable()) //if the pc has something to send { - pc.scanf("%d", &sensorNumber); - break; + pc.scanf("%d", &sensorNumber); //read what the pc says, and store it in sensorNumber variable + break; //leave the while(1) loop } } - // pc.printf("sensorNumber : %d \t " ,sensorNumber ); - return(sensorNumber); + return(sensorNumber); //return the sensorNumber } -double inputDistance(){ - // pc.printf("Enter the distance between each sensor\n "); - while (1){ + +double inputDistance() //gets the distance between each pin on the former +{ + while (1) //keep doing this + { if (pc.readable()) { pc.scanf("%lf", &sensorDistance); //has to &lf because must know the size of it before getting it in break; } - } - // pc.printf( "SensorDistance : %f", sensorDistance ); + } return(sensorDistance); - } \ No newline at end of file +}