mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2026-01-11 20:07:09 +00:00
Convert recipe examples to includes
Makes it much easier to test things - no copying'n'pasting just run the examples straight from the dir (after wiring stuff up)
This commit is contained in:
23
docs/examples/robot_buttons.py
Normal file
23
docs/examples/robot_buttons.py
Normal file
@@ -0,0 +1,23 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user