From e4ddf556a86e608f6ca9cfe2fdc99386d2e62371 Mon Sep 17 00:00:00 2001 From: admin Date: Wed, 5 Aug 2026 14:13:28 +0000 Subject: [PATCH] =?UTF-8?q?testUS.py=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- testUS.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 testUS.py diff --git a/testUS.py b/testUS.py new file mode 100644 index 0000000..daedc37 --- /dev/null +++ b/testUS.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 + +from gpiozero import DistanceSensor +from time import sleep + +trigPin = 23 +echoPin = 24 +sensor = DistanceSensor(echo=echoPin, trigger=trigPin ,max_distance=3) + +def loop(): + while True: + print('Der abstand ist : ', sensor.distance * 100,'cm') + sleep(0.05) + +if __name__ == '__main__': # Program entrance + print ('Program is starting...') + try: + loop() + except KeyboardInterrupt: # Press ctrl-c to end the program. + sensor.close() + print("Ending program") \ No newline at end of file