mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 17:50:37 +00:00
27 lines
586 B
Python
27 lines
586 B
Python
from gpiozero import Button, Robot
|
|
from gpiozero.pins.pigpio import PiGPIOFactory
|
|
from signal import pause
|
|
|
|
factory = PiGPIOFactory(host='192.168.1.17')
|
|
robot = Robot(left=(4, 14), right=(17, 18), pin_factory=factory) # remote pins
|
|
|
|
# local buttons
|
|
left = Button(26)
|
|
right = Button(16)
|
|
fw = Button(21)
|
|
bw = Button(20)
|
|
|
|
fw.when_pressed = robot.forward
|
|
fw.when_released = robot.stop
|
|
|
|
left.when_pressed = robot.left
|
|
left.when_released = robot.stop
|
|
|
|
right.when_pressed = robot.right
|
|
right.when_released = robot.stop
|
|
|
|
bw.when_pressed = robot.backward
|
|
bw.when_released = robot.stop
|
|
|
|
pause()
|