Sonar Sensor

I made a sonar sensor to sense distance. I used two ultrasonic transducers, an op-amp and a microcontroller for the job. Basically, the microcontroller creates a pulse train of about […]

I made a sonar sensor to sense distance. I used two ultrasonic transducers, an op-amp and a microcontroller for the job.

Basically, the microcontroller creates a pulse train of about 20 pulses at 40kHz, which is the frequency that the transducers are optimized for. This pulse train is sent to the transmitting transducer. Once the pulse train is finished, five additional pulses with a 180° phase shift are sent to kill the oscillation of the transducer.

An op-amp circuit is connected to the input ultrasonic transducer. The configuration of the op-amp produces a binary output whenever the analog input voltage signal is raised above a certain level. The output of the op-amp circuit is connected to a pin on the microcontroller.


The ultrasonic wave travels from the output transducer to the first object in its way and reflects back to the input transducer. The time of flight is measured with a timer on the microcontroller and reported to a computer via RS-232.

A silly interface was designed in Python (see video) that listens for messages from the board and moves an arrow along a ruler as well as displaying the distance in inches.

About Siggi