main.py 782 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import PikaStdLib
  2. import pikaRTThread
  3. import SmartLoong
  4. thread = pikaRTThread.Thread()
  5. mem = PikaStdLib.MemChecker()
  6. print('mem use max(byte): ')
  7. print(int(mem.getMax() * 1000))
  8. led1 = SmartLoong.LED()
  9. led1.setId(1)
  10. led1.enable()
  11. led1.on()
  12. key1 = SmartLoong.KEY()
  13. key1.setId(1)
  14. key1.enable()
  15. i = 0
  16. while i < 3:
  17. i = i + 1
  18. led1.on()
  19. thread.mdelay(500)
  20. led1.off()
  21. thread.mdelay(500)
  22. num_press = 0
  23. led_is_on = 0
  24. while num_press < 3:
  25. if key1.read() == 0:
  26. num_press = num_press + 1
  27. print('press num:')
  28. print(num_press)
  29. if led_is_on:
  30. led1.off()
  31. led_is_on = 0
  32. thread.mdelay(500)
  33. else:
  34. led1.on()
  35. led_is_on = 1
  36. thread.mdelay(500)
  37. thread.mdelay(50)