mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 17:50:37 +00:00
24 lines
442 B
Python
24 lines
442 B
Python
from gpiozero import Robot, Button
|
|
from signal import pause
|
|
|
|
robot = Robot(left=(4, 14), right=(17, 18))
|
|
|
|
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()
|