MIFAREReader = MFRC522.MFRC522() # Welcome message print "Welcome to LACS" # This loop keeps checking for chips. If one is near it will get the UID and authenticate while continue_reading: GPIO.output(29, True) # Scan for cards (status, TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL) # If a card is found if status == MIFAREReader.MI_OK: print "Card detected" # Get the UID of the card (status, uid) = MIFAREReader.MFRC522_Anticoll() print uid #Creating the Log software.log(uid) # If we have the UID, continue authenticated = software.auth(uid) if int(authenticated) == 1: GPIO.output(29, False) else: print "Authentication error" #Adding delay of 0.1 sec for user to enter time.sleep(0.1)
lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("Card detected",1) #log into lcd # Get the UID of the card time.sleep(0.6) (status,uid) = MIFAREReader.MFRC522_Anticoll() print uid #Using lcd to display on UID lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("Your UID:",1) #Using lcd to display on UID lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string(''.join(str(x) for x in uid),1) time.sleep(3) lcd.lcd_string("",1) #Authentication (auth,name)=software.auth(uid) if(auth==1): #Displaying Welcome message on led with User's name lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("WELCOME",1) lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string(name,1) #Trigerring Relay GPIO.output(29,False) time.sleep(lock_delay) lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string("",1) elif(auth==0): #Displaying Unauthorize attempt on LCD lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD) lcd.lcd_string("Unauthorize",1)
# Welcome message print "Welcome to LACS" # This loop keeps checking for chips. If one is near it will get the UID and authenticate while continue_reading: GPIO.output(29, True) # Scan for cards (status, TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL) # If a card is found if status == MIFAREReader.MI_OK: print "Card detected" # Get the UID of the card (status, uid) = MIFAREReader.MFRC522_Anticoll() print uid # Creating the Log software.log(uid) # If we have the UID, continue authenticated = software.auth(uid) if int(authenticated) == 1: GPIO.output(29, False) else: print "Authentication error" # Adding delay of 0.1 sec for user to enter time.sleep(0.1)