To do this scenario we have to find some components,there are
Arduino Uno Board
Ultrasonic Sensor
After find these things then we have to connect each other like below, As the first step we have to connect ultrasonic sensor to Uno board , If you look ultrasonic sensor you can see 4 Output pins in There,
- VCC Pin
- Triger Pin
- Echo Pin
- Gnd Pin,
I am gonna connect with VCC Pin with 5V supplier in Uno Board & you know 13 digital Pins in Uno board So we can choose one of digital pin to connect Triger Pin & Echo Pin with Uno board ,As a example I choose Triger Pin to "8 digital Pin" and Echo Pin to "9 digital Pin" And final Pin to "Gnd Pin" in Uno board,
After that we have connect buzzer also ,In Buzzer you can see (+)Pin & (-)Pin , we want to connect (+)Pin with one of digital number like what we did in before so I choose "10 digital Pin" to that and (-)Pin to Gnd Pin, then we have connect this to computer by using connecting cable.
Now we connected with all the things with each other and you can see it in a image below
As the next step we have to code now , to do that open your Arduino software and then go to tool and check is it connect with our Uno board and check port also, after that we have to save that in prefer location what you want and the start your code ,
And I embedded my code in below as a image, If you want ,you can copy paste it but don't forget have you change something else like digital pins number ,you have to change it in code also .