Interface HC-SR04 Ultrasonic Sensor with Raspberry Pi Pico

PHOTO EMBED

Wed Apr 13 2022 15:25:24 GMT+0000 (Coordinated Universal Time)

Saved by @ehraz786 #python

from hcsr04 import HCSR04
from time import sleep

sensor = HCSR04(trigger_pin=2, echo_pin=3, echo_timeout_us=10000)

while True:
    distance = sensor.distance_cm()
    print('Distance:', distance, 'cm')
    sleep(1)
content_copyCOPY

HC-SR04

https://microcontrollerslab.com/hc-sr04-ultrasonic-sensor-raspberry-pi-pico-micropython-tutorial/