02/07/15

Dependencies:   mbed

Dependents:   TabbedGUIMbed

UserInput.cpp

Committer:
aidanPJG
Date:
2015-09-03
Revision:
70:168d67695a65
Parent:
59:2cbbd6fea55b
Child:
71:60f06e7e50a3

File content as of revision 70:168d67695a65:

#include "mbed.h"
#include <utility>
#include <string>

extern Serial pc;
int sensorNumber;
double sensorDistance;
string date;

int inputNoOfPins()                         //gets the number of pins on a former
{
    while (1)                                                   //keep doing this
    {   
                if (pc.readable())                                  //if the pc has something to send
                {
                    pc.scanf("%d", &sensorNumber);                          //read what the pc says, and store it in sensorNumber variable
                    break;                                                  //leave the while(1) loop
                    }
             }
      return(sensorNumber);                                         //return the sensorNumber
    }   
    
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;
                    }
    }
         return(sensorDistance);
}