Code: Select all
import machine
import utime
import sys
letzte_zeit = 0
diff_erreicht = 0
def zeit_diff(schlafen):
global letzte_zeit
if utime.ticks_diff(utime.ticks_ms(), letzte_zeit) >= schlafen:
letzte_zeit = utime.ticks_ms()
diff_erreicht = 1
return(diff_erreicht)
while True:
print("I am the main program")
if zeit_diff(2) == 1:
print("do something when the time period-1 is up")
diff_erreicht = 0
#how can I program this now, so that the next If statements are executed correctly.
if zeit_diff(1000) == 1:
print("do something when the time period-2 is up")
diff_erreicht = 0
if zeit_diff(2000) == 1:
print("do something when the time period-3 .... is up")
diff_erreicht = 0
How do I have to change my subroutine so that I can query the If queries multiple times in a time-controlled manner.
Am still a newbie.