breathingLight.lua 592 B

1234567891011121314151617181920212223242526272829
  1. --- 模块功能:呼吸灯
  2. -- @author openLuat
  3. -- @module breathingLight
  4. -- @license MIT
  5. -- @copyright openLuat
  6. -- @release 2021.6.2
  7. module(...,package.seeall)
  8. require "misc"
  9. local x = 0
  10. local y = 0
  11. sys.taskInit(function()
  12. sys.wait(5000)
  13. log.info("test start")
  14. while true do
  15. if x == 0 then
  16. y = y + 4
  17. elseif x == 1 then
  18. y = y - 4
  19. end
  20. if y < 6 then
  21. x = 0
  22. elseif y >= 508 then
  23. x = 1
  24. end
  25. misc.openPwm(0, 512, y) -- 打开并且配置PWM
  26. sys.wait(8)
  27. end
  28. end)