Upload
kate-manuel
View
32
Download
1
Embed Size (px)
Citation preview
6/29/15, 11:13 AMArduino Ultrasonic Proximity Sensor
Page 1 of 5http://www.electroschematics.com/10448/arduino-ultrasonic-proximity-sensor/
Labsfree energyQ&AquizzesCommentsContact
RegisterLogin
Arduino555AlarmsAudioDIYHobbyLightsPower supplyRadioSolarTestedTools »Tutorials »Various »
Search
Arduino Ultrasonic Proximity Sensor This circuit was tested and worked properly!
Posted by T.K. Hareendran in Arduino, Tested with 2 comments Tagged with: proximity sensors
0 TweetTweet 6
This is an Arduino-based Proximity Sensor circuit wired using the popular HC-SR04 Ultrasonic rangingmodule,used here for non-contact object detection purpose. The HC-SR04 module includes ultrasonictransmitters, receiver and control circuit. You only need to supply a short pulse to the trigger input to start theranging, and then the module will send out burst of ultrasound at 40 kHz and raise its echo.
The set-up process is very simple, and best understood by referring the wiring diagram. If everything goes
377ShareShare
6/29/15, 11:13 AMArduino Ultrasonic Proximity Sensor
Page 2 of 5http://www.electroschematics.com/10448/arduino-ultrasonic-proximity-sensor/
right,you should see the burning eye of the red LED when there is no object in the safe-zone (within 5 cmfrom the HC-SR04 module), and an ear-splitting beep from the piezo-buzzer otherwise.
Arduino Ultrasonic Sensor Wiring Diagram
Arduino Sketch
1. /*2. Project: Ultrasonic Proximity Sensor3. Sensor: HC-SR044. Courtesy Note: Inspired by the Arduino Ping Sketch5. Tested At: TechNode Protolabz / June 20146. */7. //Pins for HC-SR048. const int trigPin = 13;9. //Pin which delivers time to receive echo using pulseIn()
10. int echoPin = 12;11. int safeZone = 5;12. // Pins for Indicators13. int statusLed = 11;14. int pzBzr = 10;15. void setup() {16. }17. void loop()18. {19. //raw duration in milliseconds, cm is the20. //converted amount into a distance21. long duration, cm;22. //initializing the pin states23. pinMode(trigPin, OUTPUT);24. pinMode(statusLed, OUTPUT);25. pinMode(pzBzr, OUTPUT);26. //sending the signal, starting with LOW for a clean signal27. digitalWrite(trigPin, LOW);
6/29/15, 11:13 AMArduino Ultrasonic Proximity Sensor
Page 3 of 5http://www.electroschematics.com/10448/arduino-ultrasonic-proximity-sensor/
28. delayMicroseconds(2);29. digitalWrite(trigPin, HIGH);30. delayMicroseconds(10);31. digitalWrite(trigPin, LOW);32. //setting up the input pin, and receiving the duration in uS33. pinMode(echoPin, INPUT);34. duration = pulseIn(echoPin, HIGH);35. // convert the time into a distance36. cm = microsecondsToCentimeters(duration);37. //Checking if anything is within the safezone38. // If not, keep status LED on39. // Incase of a safezone violation, activate the piezo-buzzer40. if (cm > safeZone)41. {42. digitalWrite(statusLed, HIGH);43. digitalWrite(pzBzr, LOW);44. }45. else46. {47. digitalWrite(pzBzr, HIGH);48. digitalWrite(statusLed, LOW);49. }50. delay(100);51. }52. long microsecondsToCentimeters(long microseconds)53. {54. // The speed of sound is 340 m/s or 29 microseconds per centimeter55. // The ping travels forth and back56. // So to calculate the distance of the object we take half of the travel57. return microseconds / 29 / 2;58. }
Search
0 TweetTweet 6
Arduino SecurityAlarm with ReedSwitch
Arduino SelfTimer
Arduino WaterLevel Indicator +Controller
ArduinoChristmas LEDLights Bar
377ShareShare
6/29/15, 11:13 AMArduino Ultrasonic Proximity Sensor
Page 4 of 5http://www.electroschematics.com/10448/arduino-ultrasonic-proximity-sensor/
2 Responses to "Arduino Ultrasonic Proximity Sensor"
1. Eldho varghese says: on September 20, 2014 at 12:28 pmreply
helloo,
thats a good project i think. can we increse the distance other than 5cm?? will that sensor sense morethan 5metre?? reply me sir…. i need the information..
2. Jim says: on September 23, 2014 at 8:10 pmreply
Halloween is approaching.I would love to see this expanded to include two sensors to run a servo with follow me eyes.Kind of like what is discussed here.http://www.instructables.com/id/Halloween-Props-That-Turn-to-Look-at-You-as-you-Wa/?ALLSTEPS
What do you think about this article? Leave a comment!
Name (required)
Mail (will not be published) (required)
You may add a picture too (related to electronics) no file selectedChoose File
Submit Comment
Check this checkbox to get notifications of followup comments via e-mail. You can also subscribewithout commenting.
electroschematics partners
6/29/15, 11:13 AMArduino Ultrasonic Proximity Sensor
Page 5 of 5http://www.electroschematics.com/10448/arduino-ultrasonic-proximity-sensor/
Login
Username
Password
Remember Me
Log In
Join all of us on our group
Recent Questions
I have an in-car camera that requires an electret exterior microphone.Circuit Diagram to Drive 50 SMD LED in Parallel using 12V DC220v DC to 220v AC Transformerless invertor circuit diagram needed....
recently added electronic circuits
IEEE 1394 Single And Dual Port FireWire Protective CircuitsFox Deterrent Beacon LightLight to Arduino ExperimentRotary Encoder & ArduinoOptical Mouse – Learn To Hack
Links - Policy - Disclaimer - © Copyright 2008 - 2015