top:
r1_an.py
#!/usr/bin/env python
import pifacedigitalio
pfd = pifacedigitalio.PiFaceDigital()
pfd.output_pins[0].turn_on()
print(“Relais 1 ist an”)
r1_aus.py
#!/usr/bin/env python
import pifacedigitalio
pfd = pifacedigitalio.PiFaceDigital()
pfd.output_pins[0].turn_off()
print(“Relais 1 ist aus”)
relais.py
#!/usr/bin/env python
import pifacedigitalio
import sys
total = len(sys.argv)
#print(” relais n s “)
#print(” python relais.py 1 an “)
print(“relais.py Parameter: “+sys.argv[1]+” / “+sys.argv[2])
pfd = pifacedigitalio.PiFaceDigital()
if sys.argv[2] == “an”:
pfd.relays[int(sys.argv[1])-1].turn_on()
print(“schalte Relais an”)
else:
pfd.relays[int(sys.argv[1])-1].turn_off()
print(“schalte Relais aus”)
print(“anderer Versuch:”)
pfd.relays[0].turn_on()
pfd.relays[1].turn_on()
test_piface.py
from time import sleep
import pifacedigitalio as p
p.init()
while(True):
p.digital_write(0,1) #turn on
sleep(1)
p.digital_write(0,0) #turn off
sleep(1)
using terminal to switch on and off
Last login: Fri Jan 15 20:25:20 on ttys002
berndgerstner@Bernds-MBP ~ % ssh pi@192.168.189.172 -o ForwardX11=yes
pi@192.168.189.172’s password:
Linux piface2 5.4.51+ #1333 Mon Aug 10 16:38:02 BST 2020 armv6l
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Fri Jan 15 19:25:55 2021 from 192.168.189.46
pi@piface2:~ $ pwd
/home/pi
pi@piface2:~ $ ls -l
insgesamt 1868
-rw-r–r– 1 pi pi 1885433 Okt 12 23:00 get-pip.py
-rw-r–r– 1 pi pi 139 Okt 12 23:30 r1_an.py
-rw-r–r– 1 pi pi 141 Okt 12 23:29 r1_aus.py
-rw-r–r– 1 pi pi 139 Okt 12 23:31 r2_an.py
-rw-r–r– 1 pi pi 141 Okt 12 23:31 r2_aus.py
-rw-r–r– 1 pi pi 494 Okt 13 08:08 relais.py
-rw-r–r– 1 pi pi 172 Nov 25 23:40 test_piface.py
pi@piface2:~ $ python3 r1_an.py
Relais 1 ist an
pi@piface2:~ $ python3 r1_aus.py
Relais 1 ist aus
pi@piface2:~ $ sudo shutdown -h now
pi@piface2:~ $ Connection to 192.168.189.172 closed by remote host.
Connection to 192.168.189.172 closed.
berndgerstner@Bernds-MBP ~ % exit
Saving session…
…copying shared history…
…saving history…truncating history files…
…completed.
[Prozess beendet]