02/07/15

Dependencies:   mbed

Dependents:   TabbedGUIMbed

Committer:
aidanPJG
Date:
Mon Jul 13 14:44:08 2015 +0000
Revision:
48:e9578f56534a
Child:
49:889751dd0395
Added userInput however it doesn't really work. It returns a weird negative distance and 0 for number of sensors. Or maybe the other way around

Who changed what in which revision?

UserRevisionLine numberNew contents of line
aidanPJG 48:e9578f56534a 1 #include "mbed.h"
aidanPJG 48:e9578f56534a 2
aidanPJG 48:e9578f56534a 3 extern Serial pc;
aidanPJG 48:e9578f56534a 4 int sensorNumber;
aidanPJG 48:e9578f56534a 5 float sensorDistance;
aidanPJG 48:e9578f56534a 6
aidanPJG 48:e9578f56534a 7 float input(){
aidanPJG 48:e9578f56534a 8 pc.printf("Ready to Read.\n");
aidanPJG 48:e9578f56534a 9 pc.printf("Enter the number of sensors\n");
aidanPJG 48:e9578f56534a 10 while (1){
aidanPJG 48:e9578f56534a 11 if (pc.readable())
aidanPJG 48:e9578f56534a 12 {
aidanPJG 48:e9578f56534a 13 pc.scanf("%d", &sensorNumber);
aidanPJG 48:e9578f56534a 14 pc.printf("Enter the distance between each sensor\n ");
aidanPJG 48:e9578f56534a 15 pc.scanf("%f", &sensorDistance);
aidanPJG 48:e9578f56534a 16 break;
aidanPJG 48:e9578f56534a 17 }
aidanPJG 48:e9578f56534a 18 }
aidanPJG 48:e9578f56534a 19 pc.printf("sensorNumber : %f \t sensorDistance : %d", sensorNumber, sensorDistance );
aidanPJG 48:e9578f56534a 20 return(sensorNumber, sensorDistance);
aidanPJG 48:e9578f56534a 21 }