import time
# Predefined valid RFID tags (for example purposes)
valid_rfid_tags = ["123456A", "654321B", "112233C"]
# Maximum allowed attempts
max_attempts = 3
attempts = 0
# Function to simulate granting access
def grant_access():
print("Access Granted: Door Unlocked!")
# Simulate door unlocked for 5 seconds
time.sleep(5)
print("Door Locked Again.")
# Function to trigger the alarm after 3 failed attempts
def trigger_alarm():
print("ALARM: Too many failed attempts! Security Alert!")
while True:
print("Please scan your RFID tag (Enter your tag ID):")
scanned_tag = input() # Simulate RFID input from terminal
if scanned_tag in valid_rfid_tags:
grant_access() # Correct tag, grant access
attempts = 0 # Reset the attempts counter after successful access
else:
attempts += 1
print(f"Access Denied! Attempt {attempts}/{max_attempts}.")
# If attempts exceed the maximum allowed
if attempts >= max_attempts:
trigger_alarm()
break # End the program or reset based on your requirement
# Add a short delay before next scan
time.sleep(1)