Sofia Figueroa / Mbed 2 deprecated lab_05

Dependencies:   mbed

Revision:
0:2195235c777f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lab_05.cpp	Thu Mar 07 14:21:32 2019 +0000
@@ -0,0 +1,43 @@
+#include "stdio.h"
+#include "mbed.h"
+
+Serial pc(USBTX,USBRX);
+AnalogIn sensor(p20);
+
+float heights[20] = {8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0};
+float measurements[20];
+float sum;
+
+int i,j;
+
+
+int main(void){
+    pc.printf("EW202 3321 Lab 5.1 Calibration\n");
+    
+    for (i=0; i<20; i++){
+        pc.printf("Move elevator to %f in and hit any key\n",heights[i]);
+        getchar();
+        
+        sum = 0.0;
+        
+        for(j=0; j<20; j++) {
+            sum = sum + sensor.read();
+            wait(0.1);
+            }
+            //for j=0 t0 20
+            
+            measurements[i] = sum/20.0;
+            pc.printf("At %f in got %f\n",heights[i],measurements[i]);
+            
+            }
+            
+            pc.printf("Results for cut and paste into Matlab\n\n");
+            for(i=0; i<20; i++){
+                pc.printf("%f,%f\n",heights[i],measurements[i]);
+                }
+        
+        }
+        
+
+    
+