- For this, we need to understand how the ultrasonic sensor works for this you need to go to this link
you can also check his youtube channel to know moreDISTANCE MEASUREMENT:
- to get the distance in cm we need to multiply the received travel time value from the echo pin by 0.034 and divide it by 2.
- For calculating the Area of square and circle, we need to do some mathematical operations in the program to get Area.
- For square A = (side)^2
- For circle A = pi(3.14)x(r)^2 for pi in the program I'm using "PI"
- First, I attach some male headers on the sensor to just plug sensor and play
- VCC to VCC and GND to GND
- After all connection it will look like this:
- now just we need to upload the program and run it
- Here we can are able to see the menu PRESS A to calculate the area for square PRESS B to calculate the area for circle PRESS C to measure distance in cm.
- After pressing A it calculates Ar of Square.
- After pressing B it calculated Ar of Circle.
- After pressing C it measures distance.