Obstacle detection using ultrasonic sensor

hi…eve1
this is jagan guys i need ur help in arduino programming…i m a engg student… i’m doing project…OBSTACLE DETECTOR USING ULTRASONIC SENSOR…my project wrks fine but i hav to implement servo motor fr this project which the sensor acts like radar rotates 0 to 180…I did program but it wont works…when the object detected and buzzer ll ON and the servo motor cant stop keep rotating 0 to 180…i hav to stop that servo motor wen sensor detects the object…?

exp.ino (1.26 KB)

The ultrasonic detection is outside the for loop that moves the servo. So it will not be checked while the servo is moving.

I tried servo code put it in the loop...still it cant stop rotating will u plzz correct the code sir

No, you correct it and repost it then we can tell you what you have done wrong.

Read the how to use this forum post to find out how to post code correctly here.