Guest User

Untitled

a guest
Nov 24th, 2020
24
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from machine import Timer
  2. global exit_flag
  3. from time import sleep
  4.  
  5. def on_timer(timer):
  6. print("on_timer")
  7. global exit_flag
  8. exit_flag = 1
  9. t = machine.Timer(1)
  10. t.init(mode=t.ONE_SHOT, period=3000, callback=on_timer)
  11. exit_flag = 0
  12. while(exit_flag == 0):
  13. print("exit_flag:", exit_flag)
  14. sleep(1)
  15. t.deinit()
  16. print("Now out of while!")
RAW Paste Data