Challenge

Project 2 - Measuring the distance of an object using ultrasonic sensor and also smoothen the sensor data using moving average filter

Project 2 - Measuring the distance of an object using ultrasonic sensor and also smoothen the sensor data using moving average filter

here in the above qustion we have to meausure the distance of an onject  by using ultra sonic sesnor and also smoothen the sesnor data by using average moving filter 

here in the above circuit we can see the connection i took one bread board and one ultra soniic sesnsor and one arduno first i given the connection from arduno to breadboard after for the ultra sonic sensor also i given power and ground connections from the bread board echo and trigger pin givben to the digital pins of the arduno 

here in this code in variable declaration part i declared the trigger and echo pins to the digital pins after i took some variables like distance and duration after i took the average and the total varibles to measure the average and total distance and initialized it to zero 

in the void setup part i declared the input as echo and the output as tigger and used the serial .begin to initialize the serial monitor 

in the void loop  first the trigger pin low for 2 micro seconds to clear the values in the trigger and after trigger pin again high for ten seconds and and become low agaion in this duration the signal generate go and come back and we have to capture the trigger and what is the time for signal go and come back and and were capturing this in the echo pin after by using pulse in function we caluclating the duration that how much time it takes go and come back when the echo pin is high ..echo pin is high when it recievbe the signal after i caluclating the distance by using the distance formula after i caluclating the ten distances and did the avg for the distances and print it in the serial monitor 

here we can observe in the results when i change the distance it varies and we capture that  some 10distances with in a seconds and caluclating the avg for that and showed in the serial monitor 

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.