CD4060 is the core device of ultrasonic sensor designed by Maxim company abroad. CD4060 integrates ultrasonic emission control and ultrasonic receiving control, so it is very convenient. The power supply of the chip is also 5V, which is very consistent with the design of the single-chip microcomputer. As shown in the figure, one pin is connected to the power supply of 5V, and four pins are connected to the power supply of ground, which has low power consumption and only needs a single + 5V power supply with a power supply current of 5mA; two RS-232C drivers are integrated inside. The ranging can be realized through two interfaces, and trig of IO port is used to trigger the ranging to give at least 10us high-level signal. The module automatically sends 8 square waves of 40KHz, and automatically detects whether there is signal return; if there is signal return, it outputs a high level through the IO port echo, and the duration of high level is the time from transmission to return of ultrasonic. Test distance = (high level time * sound speed (340m / s)) / 2. When a control port sends a high level of more than 10us, it can wait for the high level output at the receiving port. As soon as the output is available, the timer can be turned on for timing. When the port becomes low power, the value of the timer can be read. At this time, it is the time of this ranging, and then the distance can be calculated. Such continuous periodic measurement can reach the value of your mobile measurement. Trig is the transmitting signal end, ultrasonic emission is connected with p3.2 of MCU, echo is the output response signal, and p3.4 of MCU. By controlling the interface of trig and echo, ultrasonic distance detection can be realized.