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:
22
docs/examples/bluedot_robot_1.py
Normal file
22
docs/examples/bluedot_robot_1.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from bluedot import BlueDot
|
||||
from gpiozero import Robot
|
||||
from signal import pause
|
||||
|
||||
bd = BlueDot()
|
||||
robot = Robot(left=(4, 14), right=(17, 18))
|
||||
|
||||
def move(pos):
|
||||
if pos.top:
|
||||
robot.forward(pos.distance)
|
||||
elif pos.bottom:
|
||||
robot.backward(pos.distance)
|
||||
elif pos.left:
|
||||
robot.left(pos.distance)
|
||||
elif pos.right:
|
||||
robot.right(pos.distance)
|
||||
|
||||
bd.when_pressed = move
|
||||
bd.when_moved = move
|
||||
bd.when_released = robot.stop
|
||||
|
||||
pause()
|
||||
Reference in New Issue
Block a user