I used pyb.usb_mode('CDC+MSC') in the boot.py
Code: Select all
import pyb
import micropython
micropython.alloc_emergency_exception_buf(100)
rtc = pyb.RTC()
rtc.wakeup(10000) # every 10 sec
led1 = pyb.LED(4) # 4 = Blue
led2 = pyb.LED(3) # 3 = Yellow
pin = pyb.Pin('SW', pyb.Pin.IN, pull=pyb.Pin.PULL_UP)
def callback(line):
led1.toggle()
if pin.value(): # 1 = not pressed
led2.off()
else:
led2.on()
ext = pyb.ExtInt(pin, pyb.ExtInt.IRQ_RISING_FALLING, pyb.Pin.PULL_UP, callback)
def mainloop():
while True:
print("wakeup time")
pyb.delay(1000)
pyb.stop() # go to sleep until next wakeup
mainloop()