Created
November 6, 2017 12:11
-
-
Save tomvdb/251de94880ee6de8fe251955fbe4066c to your computer and use it in GitHub Desktop.
Maze Controlled by Flick Shield on Raspberry PI
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
import maestro | |
import signal | |
import flicklib | |
xpos = 0 | |
ypos = 0 | |
@flicklib.move() | |
def move(x, y, z): | |
global xpos | |
global ypos | |
xpos = x | |
ypos = y | |
servo = maestro.Controller() | |
servo.setAccel(0,10) | |
servo.setAccel(1,10) | |
servo.setTarget(0, 6000) | |
servo.setTarget(1, 6000) | |
while True: | |
valuex = 0 | |
valuex = (xpos * 100) - 50 | |
valuey = 0 | |
valuey = (ypos * 100) - 50 | |
print str(valuex) + "," + str(valuey) | |
#print int(valuex) | |
if xpos > 0: | |
servo.setTarget(0, 6000+int(valuex*20)) | |
servo.setTarget(1, 6000-int(valuey*20)) | |
signal.pause() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment