![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
servo and sonar
Dependencies: C12832_lcd Pulse RangeFinder Servo mbed-rtos mbed
Fork of Sprint3_Sonar by
Diff: main.cpp
- Revision:
- 10:5a9a3a5704ef
- Parent:
- 9:fa6121cc0fff
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; }