Srxon05

it-11-17/18Maketa.py

Sep 21st, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.31 KB | None | 0 0
  1. #!/usr/local/bin/python
  2.  
  3. import RPi.GPIO as GPIO
  4. import time
  5. radi=False
  6. GPIO.setwarnings(False)
  7. GPIO.setmode(GPIO.BOARD)
  8. GPIO.setup(12,GPIO.OUT)
  9. GPIO.output(12,GPIO.LOW)
  10. pin_to_circuit = 7
  11. password=""
  12. i=0
  13. def rc_time (pin_to_circuit) :
  14.     count = 0
  15.    
  16.     GPIO.setup(pin_to_circuit, GPIO.OUT)
  17.     GPIO.output(pin_to_circuit, GPIO.LOW)
  18.     time.sleep(0.02)
  19.  
  20.     GPIO.setup(pin_to_circuit, GPIO.IN)
  21.  
  22.     while (GPIO.input(pin_to_circuit) == GPIO.LOW) :
  23.         count += 1
  24.  
  25.     return count
  26.  
  27.  
  28. try:
  29.     while True:
  30.        
  31.         if rc_time(pin_to_circuit)>500:
  32.             radi=True
  33.             while(radi):
  34.                 print"Unesite sifru: "
  35.                 while(i<5):
  36.                     GPIO.output(12,GPIO.HIGH)
  37.                     time.sleep(0.25)
  38.                     GPIO.output(12,GPIO.LOW)
  39.                     time.sleep(0.5)
  40.                     i=i+1
  41.                 if(i==5):
  42.                     GPIO.output(12,GPIO.HIGH)
  43.                     i=0
  44.  
  45.                 password=str(raw_input())
  46.                 if(password=="pilab01"or password=="pilab02"):
  47.                     radi=False
  48.                     GPIO.output(12,GPIO.LOW)
  49.                 else:
  50.                     print "Pogresna lozinka!Ponovo unesite"
  51.                     i=0
  52.  
  53.         if(password=="pilab02"):
  54.             print""
  55.             print"sistem je ugasen"
  56.             break                      
  57.         if(password=="pilab01"):
  58.             print""
  59.             print "Sifra je ispravno uneta imate 10 sekundi do ponovnog ukljucenja lasera"
  60.             time.sleep(10)
  61.             print"laser je ponovo ukljucen"
  62.             password=""
  63. except KeyboardInterrupt:
  64.     pass
  65. finally:
  66.     GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment