02/07/15

Dependencies:   mbed

Dependents:   TabbedGUIMbed

Committer:
aidanPJG
Date:
Thu Sep 03 15:10:51 2015 +0000
Revision:
70:168d67695a65
Parent:
59:2cbbd6fea55b
Child:
71:60f06e7e50a3
commented and working with GUI];

Who changed what in which revision?

UserRevisionLine numberNew 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 70:168d67695a65 8 string date;
aidanPJG 48:e9578f56534a 9
aidanPJG 70:168d67695a65 10 int inputNoOfPins() //gets the number of pins on a former
aidanPJG 56:bf08d9e50ccc 11 {
aidanPJG 70:168d67695a65 12 while (1) //keep doing this
aidanPJG 70:168d67695a65 13 {
aidanPJG 70:168d67695a65 14 if (pc.readable()) //if the pc has something to send
aidanPJG 48:e9578f56534a 15 {
aidanPJG 70:168d67695a65 16 pc.scanf("%d", &sensorNumber); //read what the pc says, and store it in sensorNumber variable
aidanPJG 70:168d67695a65 17 break; //leave the while(1) loop
aidanPJG 54:9322b1b76e13 18 }
aidanPJG 56:bf08d9e50ccc 19 }
aidanPJG 70:168d67695a65 20 return(sensorNumber); //return the sensorNumber
aidanPJG 56:bf08d9e50ccc 21 }
aidanPJG 70:168d67695a65 22
aidanPJG 70:168d67695a65 23 double inputDistance() //gets the distance between each pin on the former
aidanPJG 70:168d67695a65 24 {
aidanPJG 70:168d67695a65 25 while (1) //keep doing this
aidanPJG 70:168d67695a65 26 {
aidanPJG 54:9322b1b76e13 27 if (pc.readable())
aidanPJG 54:9322b1b76e13 28 {
aidanPJG 49:889751dd0395 29 pc.scanf("%lf", &sensorDistance); //has to &lf because must know the size of it before getting it in
aidanPJG 48:e9578f56534a 30 break;
aidanPJG 48:e9578f56534a 31 }
aidanPJG 70:168d67695a65 32 }
aidanPJG 54:9322b1b76e13 33 return(sensorDistance);
aidanPJG 70:168d67695a65 34 }