-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRead.py
More file actions
32 lines (22 loc) · 719 Bytes
/
Read.py
File metadata and controls
32 lines (22 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import time
import RPi.GPIO as GPIO
import MFRC522
# Create an object of the class MFRC522
MIFAREReader = MFRC522.MFRC522()
# Welcome message
print("Looking for cards")
print("Press Ctrl-C to stop.")
# This loop checks for chips. If one is near it will get the UID
try:
while True:
# Scan for cards
(status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)
# Get the UID of the card
(status,uid) = MIFAREReader.MFRC522_Anticoll()
# If we have the UID, continue
if status == MIFAREReader.MI_OK:
# Print UID
print("UID: "+str(uid[0])+","+str(uid[1])+","+str(uid[2])+","+str(uid[3]))
time.sleep(2)
except KeyboardInterrupt:
GPIO.cleanup()