Using Ultrasonic Distance Sensor HC-SR04 with Buzzer, LED and Arduino

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 พ.ค. 2024
  • DIY Home Security - New Video: • DIY Simple PIR Motion ...
    In this Arduino Tutorial we will learn how the HC-SR04 Ultrasonic Sensor works and how to use it with Buzzer and LED.
    Required Hardware
    Arduino Board:
    goo.gl/UyGYeF (Banggood)
    amzn.to/2LZr6t4 (Amazon)
    Ultrasonic Sensor HC-SR04 :
    goo.gl/dRkWUg (Banggood)
    amzn.to/3s4SbdT (Amazon)
    Breadboard:
    goo.gl/yCa8hX (Banggood)
    amzn.to/3qxLxwm (Amazon)
    Jumper Wires:
    goo.gl/VRzUN4 (Banggood)
    amzn.to/3doetmT (Amazon)
    Buzzer: amzn.to/3ud2PkF (Amazon)
    LED: amzn.to/3qxSs8O (Amazon)
    220 Ohm Resistor: amzn.to/3jXMJXs (Amazon)
    Recommended Items:
    Use Your Muscles in Project - amzn.to/3wdL45C
    37 Sensor & Module Packages - amzn.to/3m66WeQ
    Try this Robot Arm - amzn.to/3fq8DCl
    Best Resin 3D Printer - amzn.to/39tY8KB
    Arduino Compatible Kits - bit.ly/2J2AFF7
    Banggood Spring Sale - bit.ly/3slMbOn
    Connections:
    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.
    The HC-SR04 sensor attach to the Breadboard
    The Sensor VCC connect to the Arduino Board +5V
    The Sensor GND connect to the Arduino Board GND
    The Sensor Trig connect to the Arduino Board Digital I/O 9
    The Sensor Echo connect to the Arduino Board Digital I/O 10
    Buzzer and LED
    The Buzzer attach to the Breadboard
    The Buzzer long leg (+) connect to the Arduino Board Digital 11
    The Buzzer short leg (-) connect to the Arduino Board GND
    The LED attach to the Breadboard
    The Resistor connect to the LED long leg (+)
    The Resistor other leg (from LED's long leg) connect to the Arduino Board Digital 13
    The LED short leg (-) connect to the Arduino Board GND
    Source Code: create.arduino.cc/editor/mert...
    Social Media:
    / mertarduino
    / mertarduino
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 348

  • @maker101io
    @maker101io  3 ปีที่แล้ว +15

    Source Code: create.arduino.cc/editor/mertarduinotech/b7022e05-f709-4003-b2a7-5c487ee25007/preview
    Recommended Items:
    Use Your Muscles in Project - amzn.to/3wdL45C​
    37 Sensor & Module Packages - amzn.to/3m66WeQ​
    Try this Robot Arm - amzn.to/3fq8DCl​
    Best Resin 3D Printer - amzn.to/39tY8KB​
    Arduino Compatible Kits - bit.ly/2J2AFF7​
    Banggood Spring Sale - bit.ly/3slMbOn​

    • @hyperandaimbot
      @hyperandaimbot 2 ปีที่แล้ว +1

      Bro not uploading

    • @hyperandaimbot
      @hyperandaimbot 2 ปีที่แล้ว +1

      Itt stops at 9 percent

    • @hyperandaimbot
      @hyperandaimbot 2 ปีที่แล้ว +2

      Bro how can we do it without resister

    • @hyperandaimbot
      @hyperandaimbot 2 ปีที่แล้ว

      Please send me code

    • @Cxpys
      @Cxpys ปีที่แล้ว

      what to do if i got an error message

  • @lecongquyen2189
    @lecongquyen2189 ปีที่แล้ว +3

    What a great detailed guideline! I followed step by step and it work. I will use it for my final electrical engineering project. Thanks a lot!

  • @Kona-bona
    @Kona-bona 5 ปีที่แล้ว +7

    i had this project as an exam in my informatics class , and it worked and i got straight A. thank you.

    • @PachaHooper
      @PachaHooper 3 ปีที่แล้ว

      can u send the code pls

  • @quentinb9692
    @quentinb9692 5 ปีที่แล้ว +2

    It came in a kit, first thing that I acutally got to work with my UNO. Thanks for thie vid.

  • @Ganondalf_the_grey
    @Ganondalf_the_grey 2 ปีที่แล้ว +1

    got the uno and this is a great tutorial. thanks.

  • @mrbowlingalley
    @mrbowlingalley 4 ปีที่แล้ว +4

    3 years later and we are still building this. I set safetyDistance to 25. With only LED and no buzzer. Detects my cat coming in the room. Pretty cool - I guess!

  • @marcelnalewajko3537
    @marcelnalewajko3537 3 ปีที่แล้ว +2

    Thank you! This tutorial was very good and helped me a lot

  • @shlb3692
    @shlb3692 ปีที่แล้ว

    OMG it works
    thank you so much, please keep sharing projects like this.

  • @AdityaYadav-mk4ye
    @AdityaYadav-mk4ye 6 ปีที่แล้ว +1

    Thank you very much i am starting to learn arduino and thanks to you i can learn the hardware and then i will work on software

  • @AVolt
    @AVolt 7 ปีที่แล้ว +11

    thank you so much it worked with me.
    your fan from middle east
    اخوك من الشرق الاوسط

    • @PachaHooper
      @PachaHooper 3 ปีที่แล้ว

      he man can u send the code if u got it please

    • @y.osa269
      @y.osa269 3 ปีที่แล้ว

      اخوي ممكن الكود ضروري الله يسعدك

    • @Epic_stickman90
      @Epic_stickman90 21 วันที่ผ่านมา

      @@PachaHooper the code is in pinned comment

  • @crinnovator9444
    @crinnovator9444 6 ปีที่แล้ว +12

    East or west mert is the best...... Thanks

  • @alvaronicolasgamarrapena5596
    @alvaronicolasgamarrapena5596 10 หลายเดือนก่อน

    really good video man, code is great and when i tried it worked the first time, keep the great work bro

  • @thomasalexander1563
    @thomasalexander1563 7 ปีที่แล้ว +1

    Nice tutorial,,
    Luckily find it in instructable..
    Thank you..
    Keep it

  • @theelectromaker6215
    @theelectromaker6215 3 ปีที่แล้ว

    Thank you very much, i saw many vids but any of them din't work but your worked thank you very much.

  • @AyushRaj-me8ly
    @AyushRaj-me8ly 3 ปีที่แล้ว

    I like your video, is very useful for our project. Keep making these videos :)

  • @MarkSmith-rb5mc
    @MarkSmith-rb5mc 6 ปีที่แล้ว +3

    Thanks for a well laid out and easy to understand tutorial. Keep up the good work!

  • @rushabhvaidya7930
    @rushabhvaidya7930 2 ปีที่แล้ว

    Thanks a lot you did it man!!! Thank again

  • @Dofusvidss
    @Dofusvidss 7 ปีที่แล้ว

    Thank yoou very much for your tutorials ! I'm a beginner on arduino, why don't you connect the buzzer (+) on VCC ?

  • @HAYRISHEENVASUDEVANMoe
    @HAYRISHEENVASUDEVANMoe 3 หลายเดือนก่อน

    thank you bro you are king of arduino

  • @emilusfiogbe3450
    @emilusfiogbe3450 5 ปีที่แล้ว

    merci beaucoup c'est astronomiquement instructif!!

  • @TusharSharma-is1mi
    @TusharSharma-is1mi 6 ปีที่แล้ว

    Great job yaar
    I needed this help and....

  • @LhorKhan214
    @LhorKhan214 ปีที่แล้ว +2

    hi, can you explain where did you get this value 0.034?
    Edited:
    i did a google search, its the speed of sound (343 m / s)

  • @purple_clouds3797
    @purple_clouds3797 ปีที่แล้ว

    This is just what i needed and it's very simple😆😇😇🤤

  • @STudyTime4UVikasMishraSir
    @STudyTime4UVikasMishraSir ปีที่แล้ว

    Thank you for your nice and easy video editing
    Surely helpful for beginners

    • @cubebrix5801
      @cubebrix5801 ปีที่แล้ว

      hi. can you help me, im only using led and its only blinking

  • @muhammadfirdauz5272
    @muhammadfirdauz5272 3 ปีที่แล้ว +4

    NICE!!! Saved me a thousand dlrs in school fees

  • @hkiceman001
    @hkiceman001 7 ปีที่แล้ว

    very interesting , I change the LED to a servo motor, it works .... good
    According to your code information , it means can do anything when change the led or buzzer, thank you !

    • @AhmedHassan-qe2hs
      @AhmedHassan-qe2hs 7 ปีที่แล้ว

      what is the code if i attach vibrator instead to led ???

    • @srikanthch5858
      @srikanthch5858 6 ปีที่แล้ว

      Can u send me the source code

  • @_Simon
    @_Simon 4 ปีที่แล้ว

    do the trig and echo pins need to be on a PWM signal for them to work?
    I am doing a project on the Arduino mega and using 3 of these sensors, but all of the PWM pins are being used on motor drivers. Love your videos. Best Arduino channel. Keep up the good work!

    • @hrithikjain1806
      @hrithikjain1806 4 ปีที่แล้ว

      Not really, you can use digital write/read

  • @egorkorbasov3422
    @egorkorbasov3422 7 ปีที่แล้ว +1

    Hi! I tried to do 2 things together, Like a bell ring (you push the button and hear the buzzer rings) and LDR+3colorLED. But when I press the button when there is no light it rings only when the loop of LED is over. Why is it so?

  • @Sheik_ULEM
    @Sheik_ULEM 2 ปีที่แล้ว

    Thank you this was very clear and easy to understand

  • @williammichael3913
    @williammichael3913 6 ปีที่แล้ว +3

    Hey! I love this project tysm. But I was wondering How would I increse/decrese the range so that it will turn buzzer on when someone is more farther away?
    Thanks!

    • @TK-cz3ms
      @TK-cz3ms 4 ปีที่แล้ว

      William Michael did you ever figure out?

    • @alejandroacosta6495
      @alejandroacosta6495 3 ปีที่แล้ว

      Just look the code, he configured the "Safe Distance to 5", if you want to make it in different length just change the safe distance to a greater number

    • @cheshire793
      @cheshire793 ปีที่แล้ว

      @@alejandroacosta6495yeah, my friend and i are trying that and it's not working. do you have any other suggestions?

  • @juanbriones1760
    @juanbriones1760 7 ปีที่แล้ว

    Mert Thanks for your videos tutorials. .can you please do ir remote control car with old fashion motor shield no who you solder the pins up like the video number 2

  • @namithss7966
    @namithss7966 4 ปีที่แล้ว +1

    thanks this was good work

  • @emersonrocha1097
    @emersonrocha1097 7 ปีที่แล้ว +1

    ola,fiz esse projeto com seu codigo.
    mas ele ficou aprando com led vermelho sem nada na frente,como se houvesse um obstaculo sem ter.

  • @mr.nobodoy5976
    @mr.nobodoy5976 6 ปีที่แล้ว

    teşekkürler, adamsın :)

  • @osamazafar7350
    @osamazafar7350 6 ปีที่แล้ว

    it worked
    thanks.

  • @mohdnaqibhaiqal2974
    @mohdnaqibhaiqal2974 6 หลายเดือนก่อน

    I lke the video because is short and easy to understand

  • @AnupamaNagaratne
    @AnupamaNagaratne 2 ปีที่แล้ว

    Thank u very much it works

  • @sushilsundriyal4650
    @sushilsundriyal4650 6 ปีที่แล้ว

    Sir can we use the sam circuit for vibration sensor

  • @G.V.Ramnivedan
    @G.V.Ramnivedan 7 ปีที่แล้ว

    While coding should we connect the arduino board to the bread board please tell me soon

  • @chalsu
    @chalsu 2 ปีที่แล้ว

    Hey, can I add an LCD to this project? and How will the code be written when the LCD is added?

  • @pizzulgaming6253
    @pizzulgaming6253 2 ปีที่แล้ว

    Hi .... Can explain to me about this project that use of what system ? Hopefully in full description

  • @sreekarbss5475
    @sreekarbss5475 4 ปีที่แล้ว

    Thanks bro it helped in my project

  • @deadchords4919
    @deadchords4919 6 ปีที่แล้ว +1

    digital pin 13 has a build in resistor
    so why to put another one?

  • @dhirajmandal715
    @dhirajmandal715 3 ปีที่แล้ว

    thanks it help a lot ❤❤

  • @AvighnaDaruka
    @AvighnaDaruka 2 ปีที่แล้ว

    Hi bro, did you use passive or active buzzer?

  • @RendEm14
    @RendEm14 3 หลายเดือนก่อน

    I edited your script a bit so it goes beep stop beep stop within a set range thank you for the video

  • @ahmedomaar
    @ahmedomaar 5 หลายเดือนก่อน

    Thanks for your helping, I make it

  • @HotDoggyStand
    @HotDoggyStand 4 ปีที่แล้ว

    any reason why mine is reading out distances in the 2ks. I used the code you provided us with.

  • @chaturbhujbiyani4633
    @chaturbhujbiyani4633 5 ปีที่แล้ว +2

    wow...u did it ....u saved me....i used it in science project...

    • @eoz8985
      @eoz8985 5 ปีที่แล้ว

      i also have a science fair can you explain and the coding

  • @jacoblewis8543
    @jacoblewis8543 3 ปีที่แล้ว

    Nice Job
    Ur Great with the tutorial which is very understandable and the code.
    One problem is that when I went to the source code to look it took me to ur website with no code

    • @y.osa269
      @y.osa269 3 ปีที่แล้ว

      Did you get the code? If yes please send it to me

    • @jacoblewis8543
      @jacoblewis8543 3 ปีที่แล้ว

      @@y.osa269 no
      i did not get it

  • @vishnutripathi2885
    @vishnutripathi2885 ปีที่แล้ว

    great work....very helpful

  • @ibrahimEditzFootball
    @ibrahimEditzFootball 7 หลายเดือนก่อน

    Can we make it without led

  • @sudhanshudeshpande6187
    @sudhanshudeshpande6187 5 ปีที่แล้ว

    Can u tell me the connections of same component with the arduino nano kit??

  • @melihapa3884
    @melihapa3884 2 ปีที่แล้ว +4

    Hello. There are already a lot of these examples on youtube. In your circuit the lights are either on or off. The sound either squeaks or it doesn't. I wish you had made a circuit where the intensity of sound and light increases as you get closer. :(

    • @RendEm14
      @RendEm14 3 หลายเดือนก่อน

      Bro just recode it to do that it's not that hard

  • @Umutt1316
    @Umutt1316 3 ปีที่แล้ว

    Teşekkürler işime yaradı ve bir beğeni de benden

  • @charliebell7163
    @charliebell7163 2 ปีที่แล้ว

    How would i make it louder ? and also how would i make it longer range thanks you!!

  • @assampwd
    @assampwd 7 ปีที่แล้ว

    digital pim 13 already has a resistor attatched to it. So need of that extra resisitor

  • @emersonnascimento7468
    @emersonnascimento7468 7 ปีที่แล้ว

    Por que quando a distância começa a marcar de 3 a 4 cm no monitor serial começa a ficar saltitada pra 3400 e o som tbm fica saltitando ?

  • @salmanijaz8326
    @salmanijaz8326 4 ปีที่แล้ว

    thanks it works

  • @lacombegaetan
    @lacombegaetan 6 ปีที่แล้ว

    Thanks for tis tutorial !
    Is there a way to change buzzer's volume ?

    • @charliebell7163
      @charliebell7163 2 ปีที่แล้ว

      YEAH i rlly need it to be as loud as possible

  • @phonepaseuthkhounthachack9459
    @phonepaseuthkhounthachack9459 2 ปีที่แล้ว

    It is work. Thanks bro

  • @faiksoydemir1877
    @faiksoydemir1877 5 ปีที่แล้ว +2

    bu içeriğin raspberry pi için olanını da çekermisin acaba :)

  • @giancarlosgza
    @giancarlosgza 6 ปีที่แล้ว

    Amazing video!!!!

  • @jamesmay4547
    @jamesmay4547 2 ปีที่แล้ว

    Thank you for the great video and what is the name of the background music

  • @littenarmy8513
    @littenarmy8513 7 ปีที่แล้ว

    Can you work this with a launchpad micro controller?

  • @prempanchal7721
    @prempanchal7721 3 ปีที่แล้ว

    Hey Bro, I Have 3 Pin Buzzer Sensor GND, I/O, VCC... So which connection should I do...?

  • @nurinqasrina7826
    @nurinqasrina7826 4 ปีที่แล้ว +5

    Why my led keeps on and the sensor is not working 😣

  • @andreisantos5088
    @andreisantos5088 4 ปีที่แล้ว

    i'm brazilian and liked very good so much your video, congratulations!!!

  • @yousefgamal2784
    @yousefgamal2784 6 ปีที่แล้ว

    thanks dude
    please how to add servo

  • @nyaneiko5455
    @nyaneiko5455 6 ปีที่แล้ว

    Mert abey harikasın

  • @Si-uy8qg
    @Si-uy8qg 4 หลายเดือนก่อน

    Nice video, by the way, i'm John Blas everyone.

  • @harshithraj6055
    @harshithraj6055 ปีที่แล้ว

    Only we have to do this code with computer only or we can use cellphone

  • @robotberhasil5130
    @robotberhasil5130 5 ปีที่แล้ว

    hello can you make include lcd , so i want see how long distance from lcd but still have buzzer and led , thanks

  • @JaydiEntenia
    @JaydiEntenia หลายเดือนก่อน

    yey it worked, but how do i make it so that it'll have longer distance?

  • @prashantpal8376
    @prashantpal8376 2 ปีที่แล้ว

    Arduino Uno R3 Development Board with USB Cable can we use this

  • @djeastreofficial
    @djeastreofficial 2 ปีที่แล้ว +1

    Awesome 👌🏻

  • @ikramnazri6748
    @ikramnazri6748 2 หลายเดือนก่อน

    What type of resistor you use?

  • @codgamerandmore3205
    @codgamerandmore3205 3 ปีที่แล้ว

    thanks a lot

  • @darrenchester6623
    @darrenchester6623 5 ปีที่แล้ว

    Can i use the code for the "JSN-SR04T" ultrasonic sensor variant?

  • @shrutiverma9077
    @shrutiverma9077 3 ปีที่แล้ว

    Can we directly use the led on pin 13

  • @katianuriu7506
    @katianuriu7506 3 หลายเดือนก่อน

    What type of buzzer did you use?

  • @happyguy363
    @happyguy363 6 ปีที่แล้ว

    output LEDs are continuosly ON it is not detecting the distance in edison.
    can i know how fix it?

  • @3bsily
    @3bsily 5 ปีที่แล้ว

    how i can add vibration motor with this project > same a smart blind stick please any one help me to add vibration motor

  • @rizqiput_x
    @rizqiput_x 4 ปีที่แล้ว

    can I write code so that the buzzer can sound at the time I want, for example the buzzer will be sound for 5 second if the sensor detected something.

  • @thesensiblecoderguy
    @thesensiblecoderguy 3 ปีที่แล้ว

    thanks

  • @kevinpriadinata1184
    @kevinpriadinata1184 ปีที่แล้ว

    can u make a vidio how to modify the distance

  • @_vishnu2142_
    @_vishnu2142_ ปีที่แล้ว

    Can we do this project without led and resistor ? Please reply sir

  • @rumaishafatima6053
    @rumaishafatima6053 ปีที่แล้ว

    Sir, how will it be if you connect this project with GSM modem?

  • @mohammadabas3890
    @mohammadabas3890 ปีที่แล้ว

    How can I connect two sensors in series in this case?

  • @nadamedhat8662
    @nadamedhat8662 6 ปีที่แล้ว

    thanks ..

  • @shuvamjung1639
    @shuvamjung1639 8 หลายเดือนก่อน

    Ultra sonic security system or ye same hai??

  • @gunjanchoudhary5310
    @gunjanchoudhary5310 ปีที่แล้ว

    Sir Mera coda upload nhi ho rha h uske liye mujhe library download Karna padega but Kon sa library download karu ye nhi samjh me aa rha

  • @muhammadriyan8104
    @muhammadriyan8104 4 ปีที่แล้ว

    I am lost how do u change the strength of the LED

  • @dylansworld54321
    @dylansworld54321 ปีที่แล้ว +1

    Great project! Why is my buzzer clicking instead of buzzing though?

    • @SG-gr3fl
      @SG-gr3fl ปีที่แล้ว

      Did you ever figure it out?

  • @nagalaharivavilala4186
    @nagalaharivavilala4186 7 ปีที่แล้ว

    what is the software used?? Is it keil or ardunio??

  • @chandanjha3379
    @chandanjha3379 5 ปีที่แล้ว

    Awesome I love it

  • @applefinn3933
    @applefinn3933 4 ปีที่แล้ว

    how do you change the distance of when the buzzer starts

  • @yiannisnikitakis1270
    @yiannisnikitakis1270 6 ปีที่แล้ว

    wow
    wow
    wow

  • @aveekaumsingh5398
    @aveekaumsingh5398 6 ปีที่แล้ว

    nice video........i want more ideas

  • @afnanrahman6905
    @afnanrahman6905 11 หลายเดือนก่อน

    it is working only on time if i remove the obstacle then it is still alarming and blinking led