![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Just trying to read values into Terraterm
main.cpp
- Committer:
- jkangwi
- Date:
- 2015-04-24
- Revision:
- 2:5c83943df240
- Parent:
- 1:68153aa41971
- Child:
- 3:9aab8f5b6508
File content as of revision 2:5c83943df240:
#include "mbed.h" #include "Motor.h" AnalogIn sonic(p15); Motor R(p24, p25, p26); Motor L(p21, p22, p23); float data; float sum; float average; int p; int count; int main() { while(1) { data=sonic.read(); sum=0; for(p=0; p<=50; p++) { sum =sum+data; } average= sum/50; printf("%f \n",average); while(average>.014198) { data=sonic.read(); sum=0; for(p=0; p<=50; p++) { sum =sum+data; } average= sum/50; L.speed(0.2); R.speed(0.2); printf("%f \n",average); } L.speed(0.0); R.speed(0.0); wait(.01); } }