Jun-28-2018, 08:12 PM
(Jun-28-2018, 02:27 PM)gontajones Wrote: Maybe something like this...using a control flag (thank you for your help. It works perfect. Another question. How can I add another ultrasoinc sensor to the same thing?run_script
) to avoid multiple calls oftest.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()