import RPi.GPIO as GPIO
import time

# Pin configuration
LED_PIN = 16      # Input pin to detect LED state

# GPIO setup
GPIO.setmode(GPIO.BCM)
GPIO.setup(LED_PIN, GPIO.IN)           # LED as input (powered externally)


try:
    while True:
        # Read the LED state
        led_on = GPIO.input(LED_PIN)

        if led_on:
            print("LED is ON. Unlocked.")
        
        else:
            print("LED is OFF. Locked.")
           
        time.sleep(3)  # Small delay for stability

except KeyboardInterrupt:
    print("\nExiting program.")

finally:
    GPIO.cleanup()    # Clean up GPIO states
