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