testing NFC
This commit is contained in:
parent
c3a1359339
commit
1edbf9c4ae
2
main.py
2
main.py
@ -33,7 +33,7 @@ On Windows, the native WebAuthn API will be used.
|
|||||||
"""
|
"""
|
||||||
import time
|
import time
|
||||||
import configparser
|
import configparser
|
||||||
gpie = True
|
gpie = False
|
||||||
if gpie:
|
if gpie:
|
||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
import pickle
|
import pickle
|
||||||
|
26
test.py
Normal file
26
test.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import nfc
|
||||||
|
import time
|
||||||
|
|
||||||
|
def connected(tag):
|
||||||
|
print("Tag detected:", tag)
|
||||||
|
return True
|
||||||
|
|
||||||
|
def read_nfc():
|
||||||
|
try:
|
||||||
|
clf = nfc.ContactlessFrontend('usb') # Ensure this matches your connection
|
||||||
|
print("NFC reader initialized.")
|
||||||
|
except Exception as e:
|
||||||
|
print("Failed to initialize NFC reader:", e)
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
while True:
|
||||||
|
print("Waiting for NFC tag...")
|
||||||
|
clf.connect(rdwr={'on-connect': connected})
|
||||||
|
time.sleep(1)
|
||||||
|
except Exception as e:
|
||||||
|
print("Error reading NFC tag:", e)
|
||||||
|
finally:
|
||||||
|
clf.close()
|
||||||
|
|
||||||
|
read_nfc()
|
Loading…
Reference in New Issue
Block a user