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.
16 lines
316 B
16 lines
316 B
3 years ago
|
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)
|
||
|
|