Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/python
- import RPi.GPIO as GPIO
- import time
- radi=False
- GPIO.setwarnings(False)
- GPIO.setmode(GPIO.BOARD)
- GPIO.setup(12,GPIO.OUT)
- GPIO.output(12,GPIO.LOW)
- pin_to_circuit = 7
- password=""
- i=0
- def rc_time (pin_to_circuit) :
- count = 0
- GPIO.setup(pin_to_circuit, GPIO.OUT)
- GPIO.output(pin_to_circuit, GPIO.LOW)
- time.sleep(0.02)
- GPIO.setup(pin_to_circuit, GPIO.IN)
- while (GPIO.input(pin_to_circuit) == GPIO.LOW) :
- count += 1
- return count
- try:
- while True:
- if rc_time(pin_to_circuit)>500:
- radi=True
- while(radi):
- print"Unesite sifru: "
- while(i<5):
- GPIO.output(12,GPIO.HIGH)
- time.sleep(0.25)
- GPIO.output(12,GPIO.LOW)
- time.sleep(0.5)
- i=i+1
- if(i==5):
- GPIO.output(12,GPIO.HIGH)
- i=0
- password=str(raw_input())
- if(password=="pilab01"or password=="pilab02"):
- radi=False
- GPIO.output(12,GPIO.LOW)
- else:
- print "Pogresna lozinka!Ponovo unesite"
- i=0
- if(password=="pilab02"):
- print""
- print"sistem je ugasen"
- break
- if(password=="pilab01"):
- print""
- print "Sifra je ispravno uneta imate 10 sekundi do ponovnog ukljucenja lasera"
- time.sleep(10)
- print"laser je ponovo ukljucen"
- password=""
- except KeyboardInterrupt:
- pass
- finally:
- GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment