SHARE
TWEET

Untitled

a guest Jul 19th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. import RPi.GPIO as GPIO
  3. import time
  4. import sys
  5. buzzer=10
  6. GPIO.setmode(GPIO.BCM)
  7. GPIO.setup(buzzer, GPIO.OUT)
  8. global p
  9. p = GPIO.PWM(buzzer,10)
  10. p.ChangeDutyCycle(100)
  11. p.stop()
  12. GPIO.output(buzzer,GPIO.LOW)
  13. a = 110
  14. b = 117
  15. c = 123
  16. d = 130
  17. e = 138
  18. f = 146
  19. g = 155
  20. h = 169
  21. i = 174
  22. j = 184
  23. k = 195
  24. l = 207
  25. m = 220
  26. n = 233
  27. o = 246
  28. q = 261
  29. r = 277
  30. s = 293
  31. t = 311
  32. u = 329
  33. v = 349
  34. w = 369
  35. x = 391
  36. y = 415
  37. z = 440
  38. aa = 0
  39.  
  40. led1=27
  41. led2=6
  42. led3=25
  43. led4=17
  44. led5=26
  45. led6=16
  46. led7=13
  47. led8=23
  48. led9=5
  49.  
  50.  
  51. GPIO.setwarnings(False)
  52.  
  53. GPIO.setup(22, GPIO.IN)
  54. GPIO.setup(4, GPIO.OUT)
  55. GPIO.setup(led1,GPIO.OUT)
  56. GPIO.setup(led2,GPIO.OUT)
  57. GPIO.setup(led3,GPIO.OUT)
  58. GPIO.setup(led4,GPIO.OUT)
  59. GPIO.setup(led5,GPIO.OUT)
  60. GPIO.setup(led6,GPIO.OUT)
  61. GPIO.setup(led7,GPIO.OUT)
  62. GPIO.setup(led8,GPIO.OUT)
  63. GPIO.setup(led9,GPIO.OUT)
  64. count2 = 0
  65. try:
  66.     time.sleep(1)
  67.     while True:
  68.         print ("no motion")
  69.  
  70.         if GPIO.input(22):
  71.             GPIO.output(4, True)
  72.             time.sleep(0.5)
  73.             GPIO.output(4, False)
  74.             print("Motion Detected...")
  75.             try:
  76.                 count3 = 20
  77.                 while count3 == 20:
  78.                     GPIO.output(buzzer,GPIO.LOW)
  79.                     for x in range(1):
  80.                         timing = [.5,.25,.25,.25,.25,.25,.25,.25,.25,.25,1,.25,.25,.25,.25,.25,.25,.25,.75,.25,.5,.5,.25,.25,.25,.25,.25,.25,.25,.25,.25,.25,.25,.25,.25,.25,.25,.25,.25,.75,.25,.25,.25,.75,.25,.25,.5,.25,.25,.25,.25,.25,.25,.25,.25,.25,.25,.25,.25,.25,.25,.5,.25,.25,.25,.25,.25,.25,.25,1,.5,.5,.25,.25,.25,.5,.25,.25,.25,.25,.25,.25,.5,.25,.25,.25,.25,.25,.25,1,.25,.25,.25,.25,.25,.5,1.5,.5,.5,.5,.25,1.5,.25,.25,.25,.5,.25,.75,.25,2,.5,.5,.75,.25,1.5,.25,.25,.25,.5,.25,.75,.25,.75,.25,.25,.5,.25,.25,.25,.25]
  81.                         name = [j, m, r, aa, m,aa, j, f, f, f,aa, e, f, j, m, r, m, j, o, t,s,l,r,j,aa,r,aa,l,aa,r,aa,k,j,aa,h,aa,d,d,d,aa,d,d,d,aa,g,f,e,m,r,aa,m,aa,j,h,h,h,aa,o,o,o,aa,j,m,r,aa,n,aa,j,e,m,aa,m,k,f,e,o,k,e,m,j,e,o,i,f,o,h,h,h,aa,n,o,r,s,w,z,aa,a,b,c,b,c,a,b,c,j,e,c,b,c,c,d,e,d,e,e,d,e,l,g,e,g,c,e,f,m,f,l,l, l]
  82.                         for i in range(1,len(name)):
  83.                             if name[i] == aa:
  84.                                 p.stop()
  85.                                 GPIO.output(buzzer,GPIO.LOW)
  86.                                 time.sleep(timing[i])
  87.                                 print(len(name))
  88.                             else:
  89.                                 GPIO.output(buzzer, GPIO.HIGH)
  90.                                 p.start(50)
  91.                                 print(name[i])
  92.                                 p.ChangeFrequency(name[i])
  93.                                 time.sleep(timing[i])
  94.  
  95.                                 p.stop()
  96.                                 GPIO.output(buzzer,GPIO.LOW)
  97.                                 time.sleep(0.05)
  98.  
  99.                         count3 = count3 +1
  100.                     p.stop()
  101.                     GPIO.output(buzzer,GPIO.LOW)
  102.                     GPIO.cleanup()
  103.             except KeyboardInterrupt:
  104.                 p.stop()
  105.                 GPIO.output(buzzer,GPIO.LOW)
  106.                 GPIO.cleanup()
  107.             count2 = count2+1
  108.             print(count2)
  109.             count5=0
  110.             while count<5:
  111.                 count5 = count5+1
  112.                 for i in range (4):
  113.                     LEDA=[27,6,25,17]
  114.                     LEDB=[26,16,13,23]
  115.                     if (i%2)==0:
  116.                         GPIO.output(led9,GPIO.HIGH)
  117.                         GPIO.output((LEDA[i]),GPIO.HIGH)
  118.                         GPIO.output((LEDB[i]),GPIO.HIGH)
  119.                         time.sleep(.25)
  120.                         GPIO.output((LEDA[i]),GPIO.LOW)
  121.                         GPIO.output((LEDB[i]),GPIO.LOW)
  122.                         time.sleep(.25)
  123.                     else:
  124.                         GPIO.output(led9,GPIO.LOW)
  125.                         GPIO.output((LEDA[i]),GPIO.HIGH)
  126.                         GPIO.output((LEDB[i]),GPIO.HIGH)
  127.                         time.sleep(.25)
  128.                         GPIO.output((LEDA[i]),GPIO.LOW)
  129.                         GPIO.output((LEDB[i]),GPIO.LOW)
  130.                         time.sleep(.25)
  131.  
  132.             time.sleep(3)
  133.         else:
  134.             print("No Motion")
  135. except:
  136.     GPIO.cleanup()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top