Sleep mode



  • How can I activate sleep mode, disable when input to GP1 and then go back into sleep mode?

    This is my script:

    import machine
    import urequests
    from machine import Pin
    
    
    pressed = 0
    
    def pincb(pin):
        global pressed
        pressed += 1
    
    
    p_out = Pin('GP2', mode=Pin.OUT)
    p_out.value(1)
    pin_int = Pin('GP1', mode=Pin.IN, pull=Pin.PULL_UP)
    pin_int.irq(trigger=Pin.IRQ_RISING, handler=pincb)
    
    while True:
        if pressed > 0:
            url = "(my url)"
            params = { "test": "true" }
            urequests.urlopen(url, "GET", params)
            pressed = 0
    
    

    Thank you very much!



Pycom on Twitter