haufenweise optimierungen

This commit is contained in:
Yannik Schädler 2017-12-05 22:08:22 +01:00
parent 213c4e6f3b
commit 02e2fda2de
1 changed files with 9 additions and 31 deletions

View File

@ -7,38 +7,16 @@ data = {1:"asdf"}
wert_des_schalters = False wert_des_schalters = False
while True: while True:
time.sleep(10) # Anzahl der sekunden, die gewartet wird
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
wert_des_schalters = GPIO.input(18)
if wert_des_schalters == False:
data = {1: wert_des_schalters}
with open('data.txt', 'w') as outfile:
json.dump(data, outfile)
if wert_des_schalters == True:
data = {1: wert_des_schalters}
with open('data.txt', 'w') as outfile:
json.dump(data, outfile)
#/* Sphinx Vorschlag */ #/* Sphinx Vorschlag */
'''
GPIO.setmode(GPIO.BCM) GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
while true: time.sleep(1)
sleep(10); if wert_des_schalters != GPIO.input(18) : # das ist gut
time.sleep(1) # // Contact bounce protection
if wert_des_schalters != GPIO:Input(pin_number) # das ist gut print("wert wurde geaendert")
sleep(1); // Contact bounce protection wert_des_schalters = GPIO.input(pin_number)
wert_des_schalters = GPIO.Input(pin_number) data = {1:wert_des_schalters}
data = {1:wert_des_schalters} with open('data.txt', 'w') as outfile:
with open('data.txt', 'w') as outfile: json.dump(data, outfile)
json.dump(data, outfile)
'''