![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Just trying to read values into Terraterm
Diff: main.cpp
- Revision:
- 2:5c83943df240
- Parent:
- 1:68153aa41971
- Child:
- 3:9aab8f5b6508
--- a/main.cpp Fri Apr 24 01:00:24 2015 +0000 +++ b/main.cpp Fri Apr 24 01:13:41 2015 +0000 @@ -7,32 +7,34 @@ float data; float sum; float average; -float desired; -float erro; + int p; int count; int main() { while(1) { - - for(count=0; count<=100; count++) { + 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); - desired=.012205; - erro=desired-average; - - if(erro<.001) { - L.speed(0.2); - R.speed(0.2); - } - - - wait(.1); } + L.speed(0.0); + R.speed(0.0); + wait(.01); + } +}