Both pigpio and gpiozero provide Python modules which can run on any Python capable machine (e.g. Windows, Macs, Linux etc).
Both pigpio and gpiozero allow you to control and monitor the GPIO of one or more networked Pis.
The pigpio daemon must be running on each Pi.
The following example is for a pigpio script.
#!/usr/bin/env python
import time
import pigpio
# connect to pis
pi_tom = pigpio.pi('tom') # pi_tom accesses tom's GPIO
if not pi_tom.connected:
print("connection to tom failed")
exit()
pi_dick = pigpio.pi('dick') # pi_dick accesses dick's GPIO
if not pi_dick.connected:
pi_tom.stop()
print("connection to dick failed")
exit()
pi_harry = pigpio.pi('harry') # pi_harry accesses harry's GPIO
if not pi_harry.connected:
pi_tom.stop()
pi_dick.stop()
print("connection to harry failed")
exit()
tom_dc = 0
dick_dc = 50
harry_dc = 100
PWM_GPIO = 18
pi_tom.set_mode(PWM_GPIO, pigpio.OUTPUT)
pi_dick.set_mode(PWM_GPIO, pigpio.OUTPUT)
pi_harry.set_mode(PWM_GPIO, pigpio.OUTPUT)
while True:
try:
pi_tom.set_PWM_dutycycle(PWM_GPIO, tom_dc)
pi_dick.set_PWM_dutycycle(PWM_GPIO, dick_dc)
pi_harry.set_PWM_dutycycle(PWM_GPIO, harry_dc)
tom_dc += 1
harry_dc += 2
dick_dc += 4
if tom_dc > 255:
tom_dc = 0
if dick_dc > 255:
dick_dc = 0
if harry_dc > 255:
harry_dc = 0
time.sleep(0.1)
except KeyboardInterrupt:
break
print("\nTidying up")
pi_tom.stop()
pi_dick.stop()
pi_harry.stop()