A collection of examples for using the gpiozero library for reading sensors and activating actuators
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

15 lines
316 B

from gpiozero import DistanceSensor
from time import sleep
#https://gpiozero.readthedocs.io/en/stable/recipes.html#distance-sensor
sensor = DistanceSensor(
echo=19,
trigger=26,
max_distance=4,
queue_len=5)
while True:
print('distance', sensor.distance * 100)
sleep(0.5)