PROJECT.docx

# PROJECT.docx - 20873/AHMED GAMAL EL-MORSI MOHAMED EL-MESH...

• 12

This preview shows page 1 - 6 out of 12 pages.

20873/AHMED GAMAL EL-MORSI MOHAMED EL-MESH. 4-COMP-3 ---------- NO.2 GROUP-4. Brigadier-General Doctor : HESHAM ABO EL SOOD.

Subscribe to view the full document.

How It Works – Ultrasonic Sensor It emits an ultrasound at 40 000 Hz which travels through the air and if there is an object or obstacle on its path It will bounce back to the module. Considering the travel time and the speed of the sound you can calculate the distance. The HC-SR04 Ultrasonic Module has 4 pins, Ground, VCC, Trig and Echo. The Ground and the VCC pins of the module needs to be connected to the Ground and the 5 volts pins on the Arduino Board respectively and the trig and echo pins to any Digital I/O pin on the Arduino Board.
In order to generate the ultrasound you need to set the Trig on a High State for 10 µs. That will send out an 8 cycle sonic burst which will travel at the speed sound and it will be received in the Echo pin. The Echo pin will output the time in microseconds the sound wave traveled. For example, if the object is 10 cm away from the sensor, and the speed of the sound is 340 m/s or 0.034 cm/µs the sound wave will need to travel about 294 u seconds. But

Subscribe to view the full document.

what you will get from the Echo pin will be double that number because the sound wave needs to travel forward and bounce backward. So in order to get the distance in cm we need to multiply the received travel time value from the echo pin by 0.034 and divide it by 2. 1. * Ultrasonic Sensor HC-SR04 and Arduino Tutorial 2. * 3. * by Dejan Nedelkovski, 4. * 5. * 6. */ 7. 8. // defines pins numbers 9. const int trigPin = 9 ; 10. const int echoPin = 10 ; 11. 12. // defines variables 13. long duration ; 14. int distance ; 15. 16. void setup () { 17. pinMode ( trigPin , OUTPUT ); // Sets the trigPin as an Output 18. pinMode ( echoPin , INPUT ); // Sets the echoPin as an Input 19. Serial . begin ( 9600 ); // Starts the serial communication 20. } 21. 22. void loop () { 23. // Clears the trigPin 24. digitalWrite ( trigPin , LOW ); 25. delayMicroseconds ( 2 ); 26.
27.

Subscribe to view the full document.

• Spring '19
• nb
• Pulse-width modulation, Liquid crystal display, Infrared

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern