ultrasound shit

Dependencies:   ContinuousServo Tach mbed

Files at this revision

API Documentation at this revision

Comitter:
georgezolovick
Date:
Thu Apr 26 21:03:39 2018 +0000
Parent:
3:c1fe893d0353
Commit message:
26Apr2018

Changed in this revision

stop.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r c1fe893d0353 -r 7b311ca1ad32 stop.cpp
--- a/stop.cpp	Thu Apr 26 19:44:42 2018 +0000
+++ b/stop.cpp	Thu Apr 26 21:03:39 2018 +0000
@@ -4,25 +4,26 @@
 
 ContinuousServo left(p23);
 ContinuousServo right(p26);
-AnalogIn sonar(p20);
+AnalogIn sonar(p19);
 Ticker ultra;
 Serial pc(USBTX,USBRX);
 
-float wall;
+float wall = 100.0;
 float analog;
 float range;
 
 void update() {
-    wall = 102.04*sonar.read();
+    wall = 2.3*156.25*sonar.read();
     pc.printf("%f\r\n", wall);
 }
  
 int main() {
-    ultra.attach(&update, .25);
+    ultra.attach(&update, 0.1);
+    wait(3);
     
-    while(wall>12.0) { // main code for driving goes here
-    left.speed(.5);
-    right.speed(-.5);
+    while(wall>=12.0) { // main code for driving goes here
+    left.speed(.2);
+    right.speed(-.2);
     }
     left.stop();
     right.stop();