I'm at a very early stage of python programming language so please be patient
I'm trying to make my timer working and should be quite straight forward following the tutorial...but it is not
Basically my problem is that the callback function seems to be executed just 1 time, so that the updateLed flag is not updated to true any more and the if statement is always false.
I think I'm doing some very basic error.
Could you please have a look?
In general I need to have 2 or 3 timers running simultaneously and I'm trying to set just flags values into their related callbacks in order to not block the stack and execute the code in the main loop. Is that the current approach?
Code: Select all
import pyb
updateLed = False
led = pyb.LED(4)
def statusLed():
global updateLed
updateLed=True
led.toggle()
tim1 = pyb.Timer(1)
tim1.init(freq=1)
tim1.callback(statusLed())
while True:
i = 0;
if updateLed == True:
updateLed=False
print('Test: ',i)
i = i+1