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

Поділитися
Вставка
  • Опубліковано 1 жов 2024

КОМЕНТАРІ • 355

  • @maker101io
    @maker101io  3 роки тому +17

    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​

  • @muhammadfirdauz5272
    @muhammadfirdauz5272 3 роки тому +5

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

  • @AR-dy3fu
    @AR-dy3fu 5 років тому +29

    If anyone has any problems to get the code...just copy mine.
    // defines pins numbers const int trigPin = 9; const int echoPin = 10; const int buzzer = 11; const int ledPin = 13; // defines variables long duration; int distance; int safetyDistance; void setup() { pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output pinMode(echoPin, INPUT); // Sets the echoPin as an Input pinMode(buzzer, OUTPUT); pinMode(ledPin, OUTPUT); Serial.begin(9600); // Starts the serial communication } void loop() { // Clears the trigPin digitalWrite(trigPin, LOW); delayMicroseconds(2); // Sets the trigPin on HIGH state for 10 micro seconds digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); // Reads the echoPin, returns the sound wave travel time in microseconds duration = pulseIn(echoPin, HIGH); // Calculating the distance distance= duration*0.034/2; safetyDistance = distance; if (safetyDistance

  • @wicked9737
    @wicked9737 4 роки тому +2

    No way it works the dislike button works but the circuit doesn’t

  • @Sore_YT
    @Sore_YT 10 місяців тому +1

    My Circuit Isn't working, can somebody help?

  • @nurinqasrina7826
    @nurinqasrina7826 5 років тому +5

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

  • @avishai827
    @avishai827 4 роки тому +21

    ‏i can't use the arduino file

    • @anannt7777
      @anannt7777 4 роки тому +1

      yes

    • @haritahiranvasu8288
      @haritahiranvasu8288 3 роки тому

      @Barna Lengyel Thanks!! Needed this, wasn't able to access it from link in description.

  • @AVolt
    @AVolt 7 років тому +11

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

    • @PachaHooper
      @PachaHooper 4 роки тому

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

    • @y.osa269
      @y.osa269 3 роки тому

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

    • @Epic_stickman90
      @Epic_stickman90 5 місяців тому

      @@PachaHooper the code is in pinned comment

  • @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!

  • @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)

  • @crinnovator9444
    @crinnovator9444 7 років тому +12

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

  • @dylansworld54321
    @dylansworld54321 2 роки тому +1

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

    • @SG-gr3fl
      @SG-gr3fl 2 роки тому

      Did you ever figure it out?

  • @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. :(

    • @ArzenikRawr
      @ArzenikRawr 8 місяців тому

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

  • @ashershertok4239
    @ashershertok4239 4 роки тому +6

    where the frick is the code can somepaste a sorce link to it

    • @21mejia25
      @21mejia25 4 роки тому +4

      // defines pins numbers
      const int trigPin = 9;
      const int echoPin = 10;
      const int buzzer = 11;
      const int ledPin = 13;
      // defines variables
      long duration;
      int distance;
      int safetyDistance;
      void setup() {
      pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
      pinMode(echoPin, INPUT); // Sets the echoPin as an Input
      pinMode(buzzer, OUTPUT);
      pinMode(ledPin, OUTPUT);
      Serial.begin(9600); // Starts the serial communication
      }
      void loop() {
      // Clears the trigPin
      digitalWrite(trigPin, LOW);
      delayMicroseconds(2);
      // Sets the trigPin on HIGH state for 10 micro seconds
      digitalWrite(trigPin, HIGH);
      delayMicroseconds(10);
      digitalWrite(trigPin, LOW);
      // Reads the echoPin, returns the sound wave travel time in microseconds
      duration = pulseIn(echoPin, HIGH);
      // Calculating the distance
      distance= duration*0.034/2;
      safetyDistance = distance;
      if (safetyDistance

    • @beenz2486
      @beenz2486 4 роки тому

      @@21mejia25 your a legend

    • @neev_pro
      @neev_pro Рік тому

      @@21mejia25 does it work??

    • @21mejia25
      @21mejia25 Рік тому

      @@neev_pro if I remember correctly, yes. But I couldn’t help now, since this was over 2 years ago.

    • @ahmedaymen2644
      @ahmedaymen2644 Рік тому

      ​@@21mejia25.

  • @allee5631
    @allee5631 5 років тому +2

    'void setup()'
    yanlış diyor neden acaba

  • @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.

  • @Sketch_Artist645
    @Sketch_Artist645 2 роки тому +1

    If I open the source code I can't find the code

  • @aryansuratkar1980
    @aryansuratkar1980 4 роки тому +1

    My project was unsuccessful can you help me please

  • @dylansworld54321
    @dylansworld54321 2 роки тому +1

    How can i use two led in the project

  • @jwf677
    @jwf677 3 роки тому +6

    // defines pins numbers
    const int trigPin = 9;
    const int echoPin = 10;
    const int buzzer = 11;
    const int ledPin = 13;
    // defines variables
    long duration;
    int distance;
    int safetyDistance;
    void setup() {
    pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
    pinMode(echoPin, INPUT); // Sets the echoPin as an Input
    pinMode(buzzer, OUTPUT);
    pinMode(ledPin, OUTPUT);
    Serial.begin(9600); // Starts the serial communication
    }
    void loop() {
    // Clears the trigPin
    digitalWrite(trigPin, LOW);
    delayMicroseconds(2);
    // Sets the trigPin on HIGH state for 10 micro seconds
    digitalWrite(trigPin, HIGH);
    delayMicroseconds(10);
    digitalWrite(trigPin, LOW);
    // Reads the echoPin, returns the sound wave travel time in microseconds
    duration = pulseIn(echoPin, HIGH);
    // Calculating the distance
    distance= duration*0.034/2;
    safetyDistance = distance;
    if (safetyDistance

    • @hyperandaimbot
      @hyperandaimbot 2 роки тому

      Hi 2nd line from last do we have to write any number after serial.print(distance)

    • @איילהחלק
      @איילהחלק Рік тому

      Is this a code that causes a bulb to light up at a certain distance?

  • @cassandraservo
    @cassandraservo 4 роки тому +1

    Where do u write the code?

  • @stemtube8006
    @stemtube8006 6 років тому +1

    My buzzer is sounding like a Geiger counter??? it’s working but not properly, is it the buzzer or count I fix that somehow

    • @Thajoeee
      @Thajoeee Рік тому

      to change the sound of the buzzer you need to replace the original piece of code with "if (safetyDistance

  • @bubu210741
    @bubu210741 2 роки тому

    Hi, I would like to cantacting with you somehow, because i have question about this project.
    Please send me any contact information.
    Thank you
    Gergely

  • @mateoj6694
    @mateoj6694 4 роки тому +4

    the code doesent work help

    • @y.osa269
      @y.osa269 3 роки тому

      I want the code, did you get it?

  • @munireker1773
    @munireker1773 7 років тому +1

    Merhabalar ben engel algılayan robot için buzzer eklemek istiyorum engel gördüğünde buzzer ötsün direk bu kodu eklesem çalışır mı acaba?

    • @munireker1773
      @munireker1773 7 років тому

      const int trig=10;
      const int echo=8;
      const int sol_i=2;
      const int sol_g=3;
      const int sag_i=4;
      const int sag_g=5;
      int sure=0;
      int mesafe=0;
      void setup() {
      pinMode(trig,OUTPUT);
      pinMode(echo,INPUT);
      pinMode(sol_i,OUTPUT);
      pinMode(sol_g,OUTPUT);
      pinMode(sag_i,OUTPUT);
      pinMode(sag_g,OUTPUT);
      Serial.begin(9600);
      }
      void loop()
      {
      digitalWrite(trig,HIGH);
      delayMicroseconds(1000);
      digitalWrite(trig,LOW);
      sure=pulseIn(echo,HIGH);
      mesafe=(sure/2) /28.5 ;
      Serial.println(mesafe);
      if(mesafe

    • @munireker1773
      @munireker1773 7 років тому

      Kod bu

    • @munireker1773
      @munireker1773 7 років тому

      Birde bu videodaki gibi led eklemek istiyorum

    • @munireker1773
      @munireker1773 7 років тому

      Mert Arduino Tutorial & Projects Çok teşekkürler

  • @MohamedAzizYazidi
    @MohamedAzizYazidi Місяць тому

    why do when i check the monitor to see the distance every time it put the disance then a 0 again and again
    and that makes the buzzer make noise even when the is nothing infront of the sensor

  • @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.

  • @djeastreofficial
    @djeastreofficial 3 роки тому +1

    Awesome 👌🏻

  • @lecongquyen2189
    @lecongquyen2189 2 роки тому +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!

  • @deadchords4919
    @deadchords4919 7 років тому +1

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

  • @JaydiEntenia
    @JaydiEntenia 6 місяців тому

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

  • @kiboy222
    @kiboy222 Місяць тому

    kenapa low high output input saya ga berubah warna yah

  • @mehrozali2886
    @mehrozali2886 6 років тому +3

    sir, how to increase and decrease distance range ??? please please please reply

  • @pnin2383
    @pnin2383 4 роки тому

    I've done all this but it doesn't work cause the fucking source code is not available

  • @afnanrahman6905
    @afnanrahman6905 Рік тому

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

  • @africantech5
    @africantech5 3 роки тому

    Well done sir can you pls Guide me on using pic16f877A for this project

    • @africantech5
      @africantech5 3 роки тому

      I will sincerely be grateful for quick response

  • @baarishaikh
    @baarishaikh 4 роки тому +1

    Could you please share the source code file again as the above attached link is expired.... please I need it very badly thanks :-)

  • @cyberv3rse
    @cyberv3rse 2 роки тому

    My distance is only 0 and the signal does not turn off. Can you help me for figure it out

  • @edmundcorea2993
    @edmundcorea2993 2 роки тому

    Why I can't use "serial.print/In" and "distance"

  • @dharmaputra1941
    @dharmaputra1941 4 роки тому

    But.. this project is not working well at outside.. bcoz temperature factor that can change the speed of sound value (to measure the distance)..

  • @gunjanchoudhary5310
    @gunjanchoudhary5310 2 роки тому

    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

  • @chadcuber4678
    @chadcuber4678 4 роки тому

    can anybody paste the code here??

  • @faiksoydemir1877
    @faiksoydemir1877 6 років тому +2

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

  • @_ManojKumarP-qn5kg
    @_ManojKumarP-qn5kg 2 роки тому

    Need block diagram.. circuit diagram immediately

  • @OfficialAldrxch
    @OfficialAldrxch 6 років тому +2

    Do you have the circuit diagram for this project? Urgently need it..thanks

    • @ravichandrika4824
      @ravichandrika4824 4 роки тому

      me too want the circuit diagram can any one mail it please
      (rchandrika723@gmail.com)

    • @OfficialAldrxch
      @OfficialAldrxch 4 роки тому

      @@ravichandrika4824 no need to bother.. its been a year and still no reply from the creator

    • @kaipeen2523
      @kaipeen2523 2 роки тому

      Is that works?

    • @OfficialAldrxch
      @OfficialAldrxch 2 роки тому

      @@kaipeen2523 still no reply from the creator since 2018 😂

  • @pizzulgaming6253
    @pizzulgaming6253 3 роки тому

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

  • @farhanakhair4489
    @farhanakhair4489 3 роки тому

    why this source code cannot be uploaded and copied ?

  • @psycho_spidey2724
    @psycho_spidey2724 Рік тому

    What happened when we disconnect with computer

  • @kanishkkrithik5539
    @kanishkkrithik5539 4 роки тому

    it didnt work at alll its fakee

  • @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?

  • @shuvamjung1639
    @shuvamjung1639 Рік тому

    Ultra sonic security system or ye same hai??

  • @umutpancar7008
    @umutpancar7008 4 роки тому

    iyi günler acaba bunun kodunu göremiyorum bana kodu atarmısınız

  • @error-ts3xt
    @error-ts3xt 6 років тому +1

    bro i want the led to stop when something comes near to it.......plz someone help

  • @3bsily
    @3bsily 6 років тому

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

  • @kevinpriadinata1184
    @kevinpriadinata1184 Рік тому

    can u make a vidio how to modify the distance

  • @belaaa522
    @belaaa522 8 днів тому

    THNKYOUU ITS WORKS

  • @prashantpal8376
    @prashantpal8376 3 роки тому

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

  • @steveallistair5685
    @steveallistair5685 5 років тому

    Hello!Can someone please help me by telling me the codes of 4 ultrasonic,4 LEDs,a buzzer with arduino uno.We will be really appreciate your help

  • @quentinb9692
    @quentinb9692 5 років тому +2

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

  • @marcelnalewajko3537
    @marcelnalewajko3537 4 роки тому +2

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

  • @crazynuke3222
    @crazynuke3222 3 роки тому

    How to increase distance I want 2 metres

  • @linmgkhine344
    @linmgkhine344 2 роки тому

    I would like to know How much Safety factor ? How to calculate?
    Thanks

  • @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!

    • @Kirtymonma
      @Kirtymonma 5 років тому

      William Michael did you ever figure out?

    • @alejandroacosta6495
      @alejandroacosta6495 4 роки тому

      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?

  • @iqratareen-mh4xw
    @iqratareen-mh4xw 3 місяці тому

    Thank u sir ❤❤its working

  • @manufacturingengineering-bp8il
    @manufacturingengineering-bp8il 2 місяці тому

    دروستم کرد💘

  • @Si-uy8qg
    @Si-uy8qg 9 місяців тому

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

  • @jamesmay4547
    @jamesmay4547 2 роки тому

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

  • @prempanchal7721
    @prempanchal7721 3 роки тому

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

  • @pranavyo5662
    @pranavyo5662 5 років тому

    It isn't working at all......I tried many times but isn't working

  • @alphagamingff2011
    @alphagamingff2011 3 роки тому

    Can ve use another board uno small

  • @rafabalderas8948
    @rafabalderas8948 7 років тому

    Can I connect more than 1 LED? If i wish to disconnect the buzzer l, should I delete something in the code??

  • @yash5737
    @yash5737 4 роки тому

    Where is the code??? Please help me.

  • @valeriareyes5910
    @valeriareyes5910 Рік тому

    can you send me de tinkercad?

  • @aConfusedAmp
    @aConfusedAmp 6 років тому +1

    I only have 2 GND pins and your video requires 3 (so far). What do I do?

    • @chrisnyenya5233
      @chrisnyenya5233 5 років тому

      one common ground can be used on the buzzer and LED

    • @tanvirahmad3671
      @tanvirahmad3671 4 роки тому

      Use a wire to connect it to breadboard to make it short.
      :D

  • @ArzenikRawr
    @ArzenikRawr 8 місяців тому

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

  • @tedmoir5834
    @tedmoir5834 4 роки тому

    so! WHERES THE CODE,,ALL I SEE IS PRODUCTS TO BUY,,NO CODE,,

  • @harshithraj6055
    @harshithraj6055 Рік тому

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

  • @engineernabil3857
    @engineernabil3857 6 років тому +4

    tnx

    • @akshathas4397
      @akshathas4397 4 роки тому

      hey could you please froward the code to me ? i'm unable to access it.

  • @UmmmIlovemath
    @UmmmIlovemath 3 роки тому

    how to get the app for distance

  • @xmenthacker
    @xmenthacker 5 років тому

    Can iake it with Arduino nano with same code

  • @williamkakooza4603
    @williamkakooza4603 3 місяці тому

    Well done Professor

  • @agastyadava3919
    @agastyadava3919 3 роки тому

    why the buzzer has no sound

  • @_vishnu2142_
    @_vishnu2142_ 2 роки тому

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

  • @carococo2100
    @carococo2100 3 роки тому

    The code link does not work you should update if??

  • @ahmedomaar
    @ahmedomaar 9 місяців тому

    Thanks for your helping, I make it

  • @andrewcaldera8787
    @andrewcaldera8787 4 роки тому

    does anyone have the rest of the code the website doesn't wanna work

  • @harshitkumar5246
    @harshitkumar5246 4 роки тому

    The code was not opening

  • @d.e.6571
    @d.e.6571 6 років тому

    Yaptıgınız sistemin aynısını yaptım fakat buzzerin sesi cok az cıkıyor ve bip sesi gelmiyor.İnternetten set halinde sipariş vermiştim.

  • @MrBOBALON
    @MrBOBALON 6 років тому

    When I unplug it from my computer, and attempt to use a 9v battery, it doesn't work. I see the little yellow light on the arduino fade away with no buzzing from objects near the sensor. How can I get it to run on just the 9v?

  • @JoanaRocha
    @JoanaRocha 2 роки тому

    AMO TE

  • @SMARTS-mv4nh
    @SMARTS-mv4nh 6 років тому +7

    what the problem i can't able to run this either the buzzer continuously sounds or sometimes not sounds ,i removed the light section from it

  • @allinonebedu8708
    @allinonebedu8708 2 роки тому

    Tell Uno model please ?

  • @rumaishafatima6053
    @rumaishafatima6053 2 роки тому

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

  • @ibrahimEditzFootball
    @ibrahimEditzFootball Рік тому

    Can we make it without led

  • @thomasalexander1563
    @thomasalexander1563 7 років тому +1

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

  • @AakashAakash-xr6qb
    @AakashAakash-xr6qb 11 місяців тому

    Can we use capacitor and what is the purpose ?? Bro

    • @ArzenikRawr
      @ArzenikRawr 8 місяців тому

      Why would you add a capacitor???? That just holds energy and shoves it in bursts

  • @AnupamaNagaratne
    @AnupamaNagaratne 2 роки тому

    Thank u very much it works

  • @muhammedyousufnoorullah5117
    @muhammedyousufnoorullah5117 4 роки тому

    I CAN'T UNDERSTAND ANYTHING.
    WHY IS THAT???

  • @Ganondalf_the_grey
    @Ganondalf_the_grey 3 роки тому +1

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

  • @danialaman9532
    @danialaman9532 3 місяці тому

    good