So, as you can see below, I've got two processes, t1 and t2, but I want t2 to terminate when t1's break condition is met and vice versa. Right now my solution isn't working, can anyone tell me why?
def distance1():
while True:
dist = distance(TRIG1, ECHO1)
if dist < 0.6 or dist > 6.5:
print("Nichts")
elif dist > 0.6 or dist < 6.5:
print("Entfernung1 = %.1f cm" % dist)
lcd.lcd_display_string("Achtung! Radfahr-",1)
lcd.lcd_display_string("rer beachten!",2)
break
def distance2():
while break2==False:
dist2 = distance(TRIG2, ECHO2)
if dist2 < 0.6 or dist2 > 6.5:
print("Nichts2")
elif dist2 > 0.6 or dist2 < 6.5:
print("Entfernung2 = %.1f cm" % dist2)
time.sleep(8)
lcd.lcd_clear()
break4=True
break
def distance4():
while break4==False:
dist4 = distance(TRIG4, ECHO4)
if dist4 < 3.0 or dist4 > 12.0:
print("Nichts4")
elif dist4 > 3.0 or dist4 < 12.0:
print("Entfernung4 = %.1f cm" % dist4)
lcd.lcd_display_string("Stop! Radfahrer ",1)
lcd.lcd_display_string(" durchlassen!",2)
for x in range(0, 8):
GPIO.output(LED, GPIO.HIGH)
time.sleep(1)
GPIO.output(LED, GPIO.LOW)
time.sleep(1)
lcd.lcd_clear()
break2=True
break
t1=Process(target=distance2)
t2=Process(target=distance4)
distance1()
t1.start()
t2.start()
EDIT: Sorry for constantly changing my question, but I'd like to do it with a global variable.