def wait_for_next(self): # Import this module to gain access to the RFID driver # fill in this map with the names of your card ID's # wait for a card to be detected as present print("Waiting for a card...") rfid.waitTag() print("Card present") # This demo only uses Mifare cards if not rfid.readMifare(): print("This is not a mifare card") else: # What type of Mifare card is it? (there are different types) print("Card type:" + rfid.getTypeName()) # look up the unique ID to see if we recognise the user uid = rfid.getUniqueId() # wait for the card to be removed #print("Waiting for card to be removed...") #rfid.waitNoTag() #print("Card removed") return uid
GPIO.setup(GPIO_YELLOW_LED, GPIO.OUT) while True: # wait for a card to be detected as present GPIO.output(GPIO_YELLOW_LED, GPIO.HIGH) fplog.l("Waiting for a card...","test") rfid.waitTag() fplog.l("Card is present","test") GPIO.output(GPIO_YELLOW_LED, GPIO.LOW) # This demo only uses Mifare cards if not rfid.readMifare(): fplog.l("This is not a mifare card","test") else: # What type of Mifare card is it? (there are different types) fplog.l("Card type:" + rfid.getTypeName(),"test") # get unique ID if the card uid = rfid.getUniqueId() fplog.l("Card UID:" + uid,"test") # wait for the card to be removed fplog.l("Waiting for card to be removed...","test") rfid.waitNoTag() fplog.l("Card removed","test") # END
# MAIN PROGRAM while True: # wait for a card to be detected as present print("Waiting for a card...") rfid.waitTag() print("Card present") # This demo only uses Mifare cards if not rfid.readMifare(): print("This is not a mifare card") else: # What type of Mifare card is it? (there are different types) print("Card type:" + rfid.getTypeName()) # look up the unique ID to see if we recognise the user uid = rfid.getUniqueId() try: user = cards[uid] print("User:"******"Unknown card:" + uid) # wait for the card to be removed print("Waiting for card to be removed...") rfid.waitNoTag() print("Card removed") # END
def cardType(self): return rfid.getTypeName()