Im trying to make something occur every 1/2 second interval with this code:
def doorcheck(self):
global time_digit, fredpos
current_time = millis()
current_timestring = str(current_time)
if time_digit == 5 or time_digit == 0:
print("yis")
if fredpos==4:
fredpos=0
frDoorCheck=1
self.x = self.posX[self.i]
self.y = self.posY[self.i]
print(time_digit)
if current_time > 0 and current_time < 1000:
time_digit = current_timestring[0]
if current_time > 999 and current_time < 10000:
time_digit = current_timestring[1]
if current_time > 9999 and current_time < 100000:
time_digit = current_timestring[2]
if current_time > 99999 and current_time < 1000000:
time_digit = current_timestring[3]
if time_digit == 5 or time_digit == 0:
print("yis")
if fredpos==4:
fredpos=0
frDoorCheck=1
self.x = self.posX[self.i]
self.y = self.posY[self.i]
I have printed the time_digit variable to make sure its reaching 5 or 0, but even when it does it is not printing “yis” despite being in the code TWICE to do so
What I want to happen is for the if statement at the top and bottom to reign true, and while it is several times being true, it refuses to show as true
Nathaniel O’Hare is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
6