Jun-28-2018, 02:27 PM
(This post was last modified: Jun-28-2018, 02:29 PM by gontajones.)
Maybe something like this...using a control flag (
run_script
) to avoid multiple calls of test.sh
.def main(): try: run_script = True while True: Ergebnis = MesseDistanz() print("Gemessene Entfernung: %.1f cm (Signallaufzeit: %.4fms)" % (Ergebnis[0], Ergebnis[1])) if Ergebnis[0] < 10 and run_script: os.system('/home/pi/test.sh') run_script = False if Ergebnis[0] >= 10: run_script = True time.sleep(1) except KeyboardInterrupt: print("Messung abgebrochen") GPIO.cleanup()