HI, please anyone could help me to understand why this sample code behaves this way:
it correctly waits 3 secs, prints “on_timer” and stays in the while loop (I checked this with a print inside it) because exit_flag is never set to 1 despite it’s global. Thanks for your help!
On line 6 you have:
exit_flag == 1
And it should be
exit_flag = 1
With only one “=”
Additionally, you are having a problem with global variable definition. Try this code, it will work as expected:
This discussion explains what was going on with your variable: https://forum.micropython.org/viewtopic.php?t=4814
I hope this solves your problem.
after some hours I’d better rest for a while: I rellay didn’t see the == 🙂
Regarding the global question: I see it works if I only declare the global in the callback (without the main declaration).
Can this lead to other problems?