HC-SR04 Ultrasonic Distance Sensor and Arduino (Lesson #9)

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

КОМЕНТАРІ •

  • @johnman84
    @johnman84 Місяць тому +6

    Okay.... after it taking longer than it should have, I figured out how to make the series of LEDs work!
    Even at ten inch increments!!!
    I figured out that I needed to write, threshold * 2 for the second LED. Then I did times 3 for the next, and then times 4!
    I honestly can't believe I figured it out. I'm so dang proud of myself. Lol 😎
    Thanks for the challenge!
    So pumped!!!

  • @hazelfunnehfangirl5hamburg805
    @hazelfunnehfangirl5hamburg805 Рік тому +8

    thank u helped me before getting killed in the program class dude for forgetting to save the process

  • @Dragonforge-Studios
    @Dragonforge-Studios 28 днів тому +1

    My little brother burst into laughter when he heard "Male to Female pins" lol

  • @veryvaughsome5867
    @veryvaughsome5867 12 днів тому

    Great tutorial! does everything it says and does it well. now i gotta figure out how to make it turn on leds depending on distance

  • @Studs_Studio
    @Studs_Studio 9 місяців тому +4

    this is amazing! i made it so if youre too close a buzzer starts beeping. i want to use this on an rc car to automaticly stop

    • @Science.Buddies
      @Science.Buddies  9 місяців тому +1

      Check out the rest of our tutorials and videos on our channel, we have instructions for autonomous/RC robots as well!

  • @yehonatankalandarev6343
    @yehonatankalandarev6343 11 місяців тому +3

    I want to make a disc shooter that can be attached to the arm, and I want to add a control system to it, basically when the palm "blocks" the shot, the disc shooter will not fire.
    So I thought to connect this sensor to perform this operation, do you think it is correct? Does it suit my needs?

    • @Science.Buddies
      @Science.Buddies  11 місяців тому +1

      This sensor would work to detect when an object is within a certain distance. Please see our other Arduino tutorials linked in the description of this video.

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

    Rite Buddies Dude, Worked first time awesome! TFS, GB :)

  • @maximarkhipov2186
    @maximarkhipov2186 8 місяців тому +1

    Thanks for the detailed and easy to understand video helped me a lot !!

  • @motomichinakamura6413
    @motomichinakamura6413 9 місяців тому +1

    Is there any enclosure or casing available for this setting?

  • @Pet-vk3ig
    @Pet-vk3ig 8 місяців тому

    Nice, good job

  • @CoolOjas02
    @CoolOjas02 Рік тому +5

    Code?
    Can you give doc

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

    thank you man, helped me a lot

  • @paulcarsco6029
    @paulcarsco6029 4 місяці тому +1

    Can you provide the code link please.

  • @izukq
    @izukq Рік тому +1

    Great vid! thanks

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

    How far can the sensor work in terms of distance?

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

      ~400cm

  • @Zemabri
    @Zemabri 5 місяців тому +6

    im using this against my dog, not for a distance sensor

  • @limuelmagbanua3137
    @limuelmagbanua3137 3 місяці тому +1

    I'm having trouble tryna use a grove model of ultrasonic sensors, and it keeps calculating to 0

  • @adityamandal2456
    @adityamandal2456 Рік тому +2

    In your Automatic Braking project using Ultrasonic sensor, I have changed the PING))) sensor to HCSR04. But there's a line in the code saying
    distance = readUltrasonic(pingPin)
    Now how to change that👆

    • @Science.Buddies
      @Science.Buddies  Рік тому +1

      The program in that project uses a function to read the ultrasonic sensor instead of putting all of the code directly in the loop() function. So, you would need to change the function to use two pins instead of one. For example, the call to the function could be distance = readUltrasonic(trigPin, echoPin) and then the first line of the function would be long readUltrasonic(int pin1, int pin2). You would then change the code in the function to use pin1 (corresponding to trigPin) and pin2 (corresponding to echoPin). We're glad that you asked about this because I realized there is actually an error in the existing example program - the way it's written now, the readUltrasonic function should use the "pin" variable inside the function, not "pingPin." so for example the line pinMode(pingPin, OUTPUT); should be pinMode(pin, OUTPUT). Hope that helps! We will update the example code.

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

      @@Science.Buddies Thanks for the information 👍

  • @imahumanbe1ng
    @imahumanbe1ng 7 місяців тому +1

    does this work with arduino maker uno x???

    • @Science.Buddies
      @Science.Buddies  7 місяців тому +1

      We haven't used the Maker Uno X but it is listed as fully compatible with the Arduino Uno R3, so it should.

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

    does it work outdoor if theres sunlight?

    • @Science.Buddies
      @Science.Buddies  5 місяців тому

      Yes, this sensor uses ultrasonic sound and should not be affected by lighting conditions (with the caveat that the speed of sound depends on air temperature, so that can indirectly affect the readings, but the sensor will still work).

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

    Does it work for underground dedection?

    • @Science.Buddies
      @Science.Buddies  3 місяці тому

      No, this sensor is not designed to detect underground objects. The ultrasonic waves will be reflected back and it will just measure the distance to the ground.

  • @joshwatp3783
    @joshwatp3783 7 місяців тому

    When writing the exact same code it comes up with trigpin was not declared in this scope pinmode

    • @Science.Buddies
      @Science.Buddies  7 місяців тому +2

      The Arduino code is case sensitive, make sure your code matches the example exactly (pinMode and trigPin)

    • @joshwatp3783
      @joshwatp3783 7 місяців тому

      @@Science.Buddies yeah forgot the capital for M

  • @cal7772
    @cal7772 3 дні тому

    I am definitely failing this class omg

  • @Sabbir-ln3bx
    @Sabbir-ln3bx 7 місяців тому

    how do you use it with LEDs?

    • @Science.Buddies
      @Science.Buddies  7 місяців тому

      Please see our Arduino tutorial playlist which covers LEDs: ua-cam.com/play/PLlBVuTSjOrclb0iCMSRpS_H1lSrlSVeEm.html&si=cyCw5jX3CNvyX5me

  • @SunbeamVaruna-ef3pp
    @SunbeamVaruna-ef3pp 3 місяці тому

  • @joshwatp3783
    @joshwatp3783 7 місяців тому

    Also saying pinmode was not declared in this scope

    • @jackleone1206
      @jackleone1206 3 місяці тому +1

      do "pinMode" not "pinmode" thats what got me. hope this helps someone

  • @Howdy-Harry
    @Howdy-Harry 6 місяців тому

    Amazing

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

    Does this sensor also detect the intensity of the reflected wave?

    • @Science.Buddies
      @Science.Buddies  5 місяців тому

      No, it only detects how long it took the wave to bounce back.

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

    how to do the lights?

    • @Science.Buddies
      @Science.Buddies  Рік тому

      If you check out our Arduino tutorial playlist (linked in the description) you will find other videos about controlling LEDs.

  • @GrahamEisele
    @GrahamEisele 4 місяці тому +1

    Its just reading 0 for me.

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

      you might not have the wires connected correctly make sure 5v in vcc ground in ground and that you have trigpin and echopin connected to the correct pin on the arduino to make it match with the code