I am having trouble with (I assume) either uasynco, primitives or my Pico. The following code works great but only for a limited time. Like about 30 mins.
Code: Select all
from machine import Pin
from primitives.pushbutton import Pushbutton
import uasyncio as asyncio
async def my_app():
await asyncio.sleep(600)
ledblue = machine.Pin(1,machine.Pin.OUT)
ledred = machine.Pin(2,machine.Pin.OUT)
relay = machine.Pin(18,machine.Pin.OUT)
b2=machine.Pin(26,machine.Pin.IN, machine.Pin.PULL_DOWN)
b1=machine.Pin(19,machine.Pin.IN, machine.Pin.PULL_DOWN)
relay.value(0)
def input1():
relay.value(0)
ledblue.value(1)
ledred.value(0)
def input2():
relay.value(1)
ledred.value(1)
ledblue.value(0)
pb1 = Pushbutton(b1, suppress=True)
pb2 = Pushbutton(b2, suppress=True)
pb1.long_func(input1)
pb2.long_func(input2)
loop = asyncio.get_event_loop()
loop.run_until_complete(my_app())
If I and a 'while True' statement it will go for about 12 hours before locking up and not changing the relay's state.
Any thoughts as to what is happening.