Add Pico
This commit is contained in:
34
examples/Pico_read.py
Normal file
34
examples/Pico_read.py
Normal file
@@ -0,0 +1,34 @@
|
||||
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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user