Difference between revisions of "How To Use UDS To Turn Servos"

From ESE205 Wiki
Jump to navigation Jump to search
Line 19: Line 19:
  
  
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.
+
Authors: James Shaheen, Michael Horowitz, Lucas Alcantara
  
 
[[Category:HowTos]]
 
[[Category:HowTos]]

Revision as of 20:25, 1 May 2019

Tutorial: How to use ultrasonic distance sensors to turn servo motors

Overview: When creating any vehicle, it is essential that it has the ability to avoid bumping into walls and other objects. One effective way of doing this is via the usage of ultrasonic distance sensors. By using ultrasonic distance sensors, obstacles can be evaded because they can be detected from several meters away, at which point the servo motor can be told to turn. This is done through coding things in a specific way and assembling the pieces of whatever you're turning in a way that works.

Materials: - ultrasonic distance sensors - servo motor - wires (male-female and male-male) - fan

Process: The ultrasonic distance sensor has 4 pins, which are power, trig, echo and ground. The trig pin is the pin that tells the ultrasonic distance sensor to emit ultrasonic waves, while the echo is utilized to receive the signal and send the 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.

 HoverCode.jpg HoverCode2.jpg

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.


Authors: James Shaheen, Michael Horowitz, Lucas Alcantara