diff --git a/main.py b/main.py index 395ce7e..f3409c9 100644 --- a/main.py +++ b/main.py @@ -47,7 +47,6 @@ async def peripheral_task(): async def read_task(rdr, buzzer=None): # Start listening for a card - time.sleep_ms(1000) print("Waiting for RFID/NFC card...") while True: @@ -61,7 +60,6 @@ def do_read(rdr, buzzer=None): gc.collect() last_uid = None while True: - time.sleep_ms(100) try: uid = rdr.read_passive_target(timeout=0.2) if last_uid == uid: @@ -81,10 +79,14 @@ def do_read(rdr, buzzer=None): buzzer.value(0) last_uid = uid + except Exception as e: print("Something failed:", e) pass + finally: + time.sleep_ms(100) + async def main(): try: i2c = machine.I2C(0, scl=machine.Pin(1), sda=machine.Pin(0)) @@ -103,7 +105,7 @@ async def main(): print("Found PN532 with firmware version: {0}.{1}".format(ver, rev)) pn532.SAM_configuration() - time.sleep_ms(1000) + time.sleep_ms(100) gc.collect()