Created
January 26, 2018 22:40
-
-
Save jonwitts/ec3fcf9bd93a2a6c1acbc58f63aa4668 to your computer and use it in GitHub Desktop.
Code for the CamJamEduKit3 Robot controlled using the BlueDot Android app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
from bluedot import BlueDot | |
from gpiozero import CamJamKitRobot, LED | |
from signal import pause | |
bd = BlueDot() | |
robot = CamJamKitRobot() | |
blue = LED(24) | |
red = LED(23) | |
def move(pos): | |
if pos.top: | |
robot.backward(pos.distance) | |
blue.on() | |
elif pos.bottom: | |
robot.forward(pos.distance) | |
red.on() | |
elif pos.left: | |
robot.left(pos.distance) | |
blue.on() | |
elif pos.right: | |
robot.right(pos.distance) | |
blue.on() | |
def stop() : | |
robot.stop () | |
red.off() | |
blue.off() | |
bd.when_pressed = move | |
bd.when_moved = move | |
bd.when_released = stop | |
pause () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment