How To Use UDS To Turn Servos
Tutorial: How to use ultrasonic distance sensor to steer a hovercraft
Overview: When creating any vehicle, it is essential that it has the ability to navigate without bumping into walls and other objects. One effective way of doing this is via the usage of ultrasonic distance sensors. By using ultrasonic distance sensor, obstacles can be evaded because they can be sensed several meters away, or several centimeters away and turn the fan. This is done through a process of both coding and usage of hardware.
Materials: -ultrasonic distance sensors -servo motor -wires -fan
Process: The process is as follows: The ultrasonic distance sensor has 4 pins, which are power, trig, echo and ground. The trig pin can be used transmit sound, while the echo is utilized to receive the signal and read information to the arduino. Both of these are digital pins. The obstacle detection code is placed below, however the way it works can be simplified to the following procedure. First, the distance sensor is used to calculate the distance from the object in front of the hoverboard. If the object is within a distance of our choosing, then this information is relayed to the arduino which in turn calls the servo motor to turn in direction. Before the completed, however, the direction it is turning must be checked to guarantee the hoverboard is not just turning into another object. This is the process generalized.
Now that the coding has been established, the wiring and connection to the servo motor must be explained. The servo motor is wired to ground, 5v and a digital pin. The servo motor is utilized, in coding, by inputting the angle change that we want to occur after an object is sensed. However, because the angle is not saved, it was necessary to create a method that rotates the motor and then records the current status that is at. The coding for the servo motor is seen below with the servo motor code.
Lastly, to concoct this, an illustration of a possible circuit can be seen below. This displays the echo, trig, ground and power pins as well as a breadboard.