I created a system in which an ultrasonic sensor detected motion at a certain distance and sent a message to a servo to spin the motor 180 degrees. I used code found in the link below to get my system to function properly.
Servo Motor & Ultrasonic Sensor – Arduino Project Hub
The step process was pretty simple. All I had to do was connect the ultrasonic sensor and servo to the Arduino through a breadboard, upload the code to the Arduino, and then place an object in front of the sensor to see if it worked.
The ultrasonic sensor detects objects by sending out a very high frequency out one speaker and receiving the sound back in a microphone. The sensor uses the amount of time it takes for that sound to travel, hit something, and come back to get received to determine the distance something is from the sensor. Once the sensor detects something in front of it, it sends a signal to the servo to open, or rotate 180 degrees. Then, once the object that the sensor detected is no longer detected, it sends a signal to the servo to close, or rotate back 180 degrees, to its original position.
Recent Comments