This is the code:
def check_ultra():
global arduinoSerialData,y,i
y=None
i=None
while True:
if arduinoSerialData.inWaiting() > 1:
myData = arduinoSerialData.readline()
myData = str(myData)
myData = myData.replace("b'", '')
myData = myData.replace("\\r\\n'", str(0))
myData = myData.replace("\\r00.000", str(0))
myData = myData.replace("\\r00.000", str(0))
if myData.find("b"):
myData_b = myData.replace("a", str(0))
if float(myData_b) < 15 and float(myData_b) > 1:
y=1
return y
if myData.find("a"):
myData_a = myData.replace("b", str(0))
if float(myData_a) < 15 and float(myData_a) > 1:
y=2
i=1
return i
return y
else:
y=0
return y
m1=0
count=1
y=0
i=0
y == 0
while y==None or y==0:
i=0
y=None
check_ultra()
while y==2 and i==1:
y=None
i=None
print("Hello")
break
The problem is with the y==2 loop.For some reason it keeps repeating itself, even if y=None.Anyone know how to solve this, I've been on it the whole day.Thanks!
Indentation error. Put break inside the loop.
For example:
for val in "string":
if val == "i":
break
print(val)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.