I’m doing my project regarding 40khz ultrasonic sensor which will be used to get accurate distance measurements. I have a separate transmitter and receiver transducer. I want to get the time between the moment my transmitter transmitted the waves and the time my receiver received it. However, I couldn’t actually make it work. Attached below is the code I’m using.
I’m sending pulses of 40khz waves through the transmitter whose pin is connected to pin 10, then the receiver which is connected to analog pin 0 will measure the voltage peak of the wave it received which is assumed to correspond to the duration the wave has travelled. This code I used is from Mr. Kerry Wong’s blog (A Sensitive DIY Ultrasonic Range Sensor – Kerry D. Wong). However, i’m not quite sure if the code is right since i’m not getting accurate results. Can anyone help me? I would really appreciate that. Thank you in advance.
sensor.ino (1.35 KB)