WiFiMCU Based on EMW3165 - User Manual

2 Breathing LED -use PWM module

A breathing LED could be easily setup by the PWM function on the WiFiMCU board.

STEP 1, Find a LED with dupont lines. Connect the anode to D1(or whatever pin that supports PWM function) while the cathnode to a GND pin on WiFiMCU board.

STEP 2, Save the Lua scripts below as “Breathing_LED.lua”.

1.print("---WiFiMCU Demo---")

2.print("Breathing LED")

3.pin = 1

4.freq =10000

5.duty =0

6.dir = 1

7.tmr.start(1,50,function()

8. if dir ==1 then

9. duty = duty + 5

10. if duty>100 then

11. duty =100

12. dir = 0

13. end

14. else

15. duty = duty - 5

16. if duty< 0 then

17. duty = 0

18. dir = 1

19. end

20. end

21. pwm.start(pin,freq,duty)

22.end)

STEP 3, Upload the scripts via WiFiMCU STUDIO, Run this script.