大家好,我有一个非常好用的python代码,只是我想更改这段代码来读取几个标签。标签保存在变量“goodUID”中。
有人可以帮帮我吗?
提前感谢
#!/usr/bin/env python
from pirc522 import RFID # RFID
import time # delays
import RPi.GPIO as GPIO # switch on/off LEDs
goodUID = [[197,65,33,217,124],[70,109,31,217,237],[103,165,330,57,324],[324,57,217,70,237],[97,147,455,145,245]] # replace by correct UID
LEDverte = 15 # Green LED pin 15
LEDrouge = 16 # Red LED pin 16
rc522 = RFID()
GPIO.setup(LEDverte,GPIO.OUT)
GPIO.setup(LEDrouge,GPIO.OUT)
while True:
refus = 0
rc522.wait_for_tag()
(error, tag_type) = rc522.request()
if not error:
(error, uid) = rc522.anticoll()
if not error:
for i in range(0, 4):
if uid[i] != goodUID[i]:
refus = refus + 1
if refus == 0:
GPIO.output(LEDverte,GPIO.HIGH)
time.sleep(2)
GPIO.output(LEDverte,GPIO.LOW)
print("UID: " + str(uid))
else:
GPIO.output(LEDrouge,GPIO.HIGH)
time.sleep(2)
GPIO.output(LEDrouge,GPIO.LOW)
print("UID: " + str(uid))
如何添加这些标记:
goodUID = [70,109,31,217,237] # correct UID
goodUID = [197,65,33,217,124] # correct UID
goodUID = [103,165,330,57,324] # correct UID
goodUID = [324,57,217,70,237] # correct UID
goodUID = [97,147,455,145,245] # correct UID