Project 2 - Measuring the distance of an object using ultrasonic sensor and also smoothen the sensor data using moving average filter
Dear sir/madam,
Please find attached my second and final project submission!! This week's project was absolutely great- reading the sensor's data sheet, understanding how sound sensors work and how their conversions are handled and most interestingly, because my first attempt included 2 arduinos over I2C (there is a particular line in the challenge text under "Expected Outcomes" that mentions 2 arduinos, but a few TSEs said that it's not really necessary), I finally had the chance to learn and practice a little more with bit shifts and union bit extractions since I2C communications only transfer one byte at a time.
I have attached a .BRD file of the circuit as well as screenshots of it working. Here is the link to it as well. I'd like to make a small note here: as I've mentioned in my source code, the arithmetic of converting the speed of sound into the required units causes a relatively significant loss in distance measurement due to floating point arithmetic precision (the distances are off by approx. -1.80cms; they are closer by approx. 1.80cms.) I have chosen this side effect over precisely using the required conversion value for two reasons:
- I wanted to generalise the program as much as possible and prevent hardcoding;
- I assumed that this kind of setup might be used as a parking sensor or a cruise control throttle sensor and therefore relatively closer distances (within reason) would lead to relatively safer autonomous driving decisions being made.
Awaiting your feedback,
Best regards,
Rahul Singh