21 lines
479 B
Python
21 lines
479 B
Python
import RPi.GPIO as GPIO
|
|
from time import sleep
|
|
import sys
|
|
from mfrc522 import SimpleMFRC522
|
|
reader = SimpleMFRC522()
|
|
|
|
#GPIO.setmode(GPIO.BCM)
|
|
#print(GPIO.getmode())
|
|
#GPIO.setup(37, GPIO.IN)
|
|
|
|
try:
|
|
while True:
|
|
#if GPIO.input(37) == 1:
|
|
# print("+")
|
|
#py sleep(0.1)
|
|
print("Hold a tag near the reader")
|
|
id, text = reader.read()
|
|
print("ID: %s\nText: %s" % (id,text))
|
|
sleep(1)
|
|
except KeyboardInterrupt:
|
|
GPIO.cleanup() |