Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. import RPi.GPIO as GPIO
  2. import time
  3.  
  4. GPIO.setwarnings(False)
  5. GPIO.setmode(GPIO.BOARD)
  6.  
  7. Przycisk_PIN = 16
  8. Jasnosc_PIN = 18
  9.  
  10. jasnosc_dzien = 10
  11. jasnosc_noc = 3
  12.  
  13. GPIO.setup(Przycisk_PIN,GPIO.IN,pull_up_down=GPIO.PUD_UP)
  14. GPIO.setup(Jasnosc_PIN,GPIO.IN)
  15.  
  16. while True:
  17.  
  18. while GPIO.input(Jasnosc_PIN) == GPIO.LOW:
  19. print("Dzień, Ustawiona jasność:")
  20. print(jasnosc_dzien)
  21. time.sleep(5)
  22. while GPIO.input(Jasnosc_PIN) == GPIO.HIGH:
  23. print("Noc, Ustawiona jasność:")
  24. print(jasnosc_noc)
  25. time.sleep(5)
  26.  
  27. GPIO.wait_for_edge(Przycisk_PIN, GPIO.RISING)
  28. start = time.time()
  29. time.sleep(0.2)
  30.  
  31. while GPIO.input(Przycisk_PIN) == GPIO.HIGH:
  32. time.sleep(0.01)
  33. length = time.time()-start
  34.  
  35. if length > 1:
  36. jasnosc_noc += 1
  37. print ("Jasność Noc:")
  38. print(jasnosc_noc)
  39. else:
  40. jasnosc_dzien +=1
  41. print ("Jasność Dzień:")
  42. print(jasnosc_dzien)
  43.  
  44. while jasnosc_noc == 15:
  45. jasnosc_noc = 0
  46. while jasnosc_dzien == 15:
  47. jasnosc_dzien = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement