ver1
Dependencies: mbed
Diff: main.cpp
- Revision:
- 1:9d0c57c475ce
- Parent:
- 0:b40d3d1793b1
--- a/main.cpp Wed Apr 04 02:10:50 2018 +0000 +++ b/main.cpp Wed Apr 04 06:12:54 2018 +0000 @@ -6,8 +6,12 @@ int main() { while(1){ - distance = ain.read(); - pc.printf("Distance:%f\n\r",distance); + double x = 0; + for(int i=0;i<10;i++){ + distance = 53.444*pow(double(ain.read()),-1.736)/10; + x += distance; + } + pc.printf("Distance:%f\n\r",x/10); wait(0.5); } }