Open
Description
mpy ver: v1.17 generic esp8266
board: dmini
description:
the board has a builtin rgb light, which could be control by pin (15, 12, 13)
i want it to do blink over and over, but the code only work for about 2 or 3 times, then the whole program will crash and reboot
here is the code in boot.py
import time
from machine import Pin, Timer, PWM
print("boot start")
def rgbBlink(rv, gv, bv, onTime):
r, g, b = PWM(Pin(15)), PWM(Pin(12)), PWM(Pin(13))
r.init(duty=rv)
g.init(duty=gv)
b.init(duty=bv)
time.sleep_ms(onTime)
r.deinit()
g.deinit()
b.deinit()
print("before doBlink")
def doBlink():
tim = Timer(-1)
tim.init(
period=3000,
mode=Timer.PERIODIC,
callback=lambda t: rgbBlink(255, 128, 128, 1500)
)
doBlink()
print("after doBlink")
gc.collect()