servo and sonar

Dependencies:   C12832_lcd Pulse RangeFinder Servo mbed-rtos mbed

Fork of Sprint3_Sonar by Sprint One

Files at this revision

API Documentation at this revision

Comitter:
davidqpinho
Date:
Fri Apr 24 10:44:25 2015 +0000
Parent:
9:fa6121cc0fff
Commit message:
dsadsa
;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r fa6121cc0fff -r 5a9a3a5704ef main.cpp
--- a/main.cpp	Fri Apr 24 10:16:05 2015 +0000
+++ b/main.cpp	Fri Apr 24 10:44:25 2015 +0000
@@ -13,6 +13,7 @@
 
 float sonar_data;
 int base_servo_pos = 1000;
+float limit=2;
 
 
 Servo s1(p21);
@@ -50,9 +51,9 @@
 
 float ajusting_sonardata(float data)
 {
-    if(data>0.3)
+    if(data>limit)
     {
-        return 0.3;
+        return limit;
         }
     else{
         return data;
@@ -73,7 +74,7 @@
     while (1)   {
         sonar_data = rf.read_m();
         base_servo_Intelligence.lock();
-        base_servo_pos = 2200-((1400*ajusting_sonardata(sonar_data)/0.3));         
+        base_servo_pos = 800+((1400*ajusting_sonardata(sonar_data)/limit));         
         base_servo_Intelligence.unlock();        
         WAITT;
     }