A simple Ultrasonic Sensor showcase which infinitely moves from left to right using a Servo Motor. If an object is detected along its path, the LED and Buzzer will go HIGH.
-
Download and install Arduino IDE.
-
Include Servo.h library.
-
Modify object distance detection to your liking.
if (distance <= N) : Line 53 & 74
-
Before uploading the code, make sure that you have selected the correct BOARD and PORT of your Arduino by going to Tools->Board and Tools->Port.
Verify and Upload