Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import RPi.GPIO as GPIO
- import time
- GPIO.setwarnings(False)
- GPIO.setmode(GPIO.BOARD)
- Przycisk_PIN = 16
- Jasnosc_PIN = 18
- jasnosc_dzien = 10
- jasnosc_noc = 3
- GPIO.setup(Przycisk_PIN,GPIO.IN,pull_up_down=GPIO.PUD_UP)
- GPIO.setup(Jasnosc_PIN,GPIO.IN)
- while True:
- while GPIO.input(Jasnosc_PIN) == GPIO.LOW:
- print("Dzień, Ustawiona jasność:")
- print(jasnosc_dzien)
- time.sleep(5)
- while GPIO.input(Jasnosc_PIN) == GPIO.HIGH:
- print("Noc, Ustawiona jasność:")
- print(jasnosc_noc)
- time.sleep(5)
- GPIO.wait_for_edge(Przycisk_PIN, GPIO.RISING)
- start = time.time()
- time.sleep(0.2)
- while GPIO.input(Przycisk_PIN) == GPIO.HIGH:
- time.sleep(0.01)
- length = time.time()-start
- if length > 1:
- jasnosc_noc += 1
- print ("Jasność Noc:")
- print(jasnosc_noc)
- else:
- jasnosc_dzien +=1
- print ("Jasność Dzień:")
- print(jasnosc_dzien)
- while jasnosc_noc == 15:
- jasnosc_noc = 0
- while jasnosc_dzien == 15:
- jasnosc_dzien = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement