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.
lab_05.cpp
- Committer:
- sofia_fig
- Date:
- 2019-03-07
- Revision:
- 0:2195235c777f
File content as of revision 0:2195235c777f:
#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]);
}
}