Ich programmiere gerade den "Prozessor" für meine Haussteuerung mit Python, hab allerdings ein paar kleine Probleme.
Hier mein Code:
Code: Alles auswählen
if GPIO23_in == "1":
print "erkannt dass gpio23 input"
if ( GPIO.input(16) == True ):
print "erkannt dass schalter gedruckt"
dateiname = "/var/www/settings/zuweisungen/GPIO2.txt"
a = []
with open(dateiname, 'r') as f:
for line in f:
a.append(int(line))
akt1= a[1]
akt2= a[2]
akt3= a[3]
print akt1
print akt2
print akt3
dateiname = "/var/www/settings/onoff.txt"
a = []
with open(dateiname, 'r') as f:
for line in f:
a.append(int(line))
print a[akt1]
print a[akt2]
print a[akt3]
if a[akt1] == a[akt2]:
if a[akt2] == a[akt3]:
if a[akt1] == "1":
GPIO.output(akt1, GPIO.LOW) //hier problem 1
GPIO.output(akt2, GPIO.LOW)
GPIO.output(akt3, GPIO.LOW)
print "alle ein"
time.sleep(2)
elif a[akt1] == "0":
GPIO.output(akt1, GPIO.HIGH)
GPIO.output(akt2, GPIO.HIGH)
GPIO.output(akt3, GPIO.HIGH)
print "alle aus"
time.sleep(2)
else:
GPIO.output(akt1, GPIO.HIGH)
GPIO.output(akt2, GPIO.HIGH)
GPIO.output(akt3, GPIO.HIGH)
print "alle aus"
time.sleep(2)
else:
GPIO.output(akt1, GPIO.HIGH)
GPIO.output(akt2, GPIO.HIGH)
GPIO.output(akt3, GPIO.HIGH)
print "alle aus"
time.sleep(2)
Code: Alles auswählen
GPIO.output(PIN_NUMMER, GPIO.HIGH)
Code: Alles auswählen
GPIO.output(akt3, GPIO.HIGH)
Traceback (most recent call last):
File "fertig/processor.py", line 564, in <module>
GPIO.output(akt2, GPIO.HIGH)
ValueError: The channel sent is invalid on a Raspberry Pi
2. Wollte ich noch fragen ob es die Möglichkeit gibt in eine bestimmte Zeile einer Datei zu schreiben.
und 3. und letztens würde ich mich über Tipps freuen den Code etwas zu verkürzen.
60 Zeilen pro Pin und dass ohne Speicherung sind doch ziemlich viel ^^
Mir fehlt es wohl noch an einigen Basics, weis allerdings nicht nach was ich am besten suchen soll.
Betreibe eher Learning by doing und werde nachdem dieses "Großprojekt" abgeschlossen ist nicht mehr all zu viel mit Python machen, weshalb ich nicht unbedingt Lust hab jetzt Tagelang Basics zu pauken...
Hoffe ihr habt ein paar Tipps für mich
mfg
Fenestro