mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 17:50:37 +00:00
Add more advanced and remote recipes
This commit is contained in:
26
docs/examples/remote_button_robot.py
Normal file
26
docs/examples/remote_button_robot.py
Normal file
@@ -0,0 +1,26 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user