Files
micropython-mfrc522/examples/Pico_read.py
danjperron 77071b6fd3 Add Pico
2021-02-09 22:20:54 -05:00

35 lines
719 B
Python

from mfrc522 import MFRC522
def uidToString(uid):
mystring = ""
for i in uid:
mystring = "%02X" % i + mystring
return mystring
reader = MFRC522(spi_id=0,sck=2,miso=4,mosi=3,cs=1,rst=0)
print("")
print("Place card before reader to read from address 0x08")
print("")
try:
while True:
(stat, tag_type) = reader.request(reader.REQIDL)
if stat == reader.OK:
(stat, uid) = reader.SelectTagSN()
if stat == reader.OK:
print("Card detected %s" % uidToString(uid))
else:
print("Authentication error")
except KeyboardInterrupt:
print("Bye")