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
UserInput.cpp
00001 #include "mbed.h" 00002 #include <utility> 00003 #include <string> 00004 00005 extern Serial pc; 00006 int sensorNumber; 00007 double sensorDistance; 00008 string date; 00009 00010 int inputNoOfPins() //gets the number of pins on a former 00011 { 00012 while (1) //keep doing this 00013 { 00014 if (pc.readable()) //if the pc has something to send 00015 { 00016 pc.scanf("%d", &sensorNumber); //read what the pc says, and store it in sensorNumber variable 00017 break; //leave the while(1) loop 00018 } 00019 } 00020 return(sensorNumber); //return the sensorNumber 00021 } 00022 00023 double inputDistance() //gets the distance between each pin on the former 00024 { 00025 while (1) //keep doing this 00026 { 00027 if (pc.readable()) 00028 { 00029 pc.scanf("%lf", &sensorDistance); //has to &lf because must know the size of it before getting it in 00030 break; 00031 } 00032 } 00033 return(sensorDistance); 00034 } 00035 string inputDate() 00036 { 00037 while (1) //keep doing this 00038 { 00039 if (pc.readable()) 00040 { 00041 pc.scanf("%s", &date); //has to &lf because must know the size of it before getting it in 00042 break; 00043 } 00044 } 00045 return(date); 00046 }
Generated on Fri Jul 15 2022 03:23:27 by
1.7.2