New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Vlog1.py #124

Closed
wants to merge 1 commit into
base: master
from
Jump to file or symbol
Failed to load files and symbols.
+44 −0
Diff settings

Always

Just for now

Create Vlog1.py

  • Loading branch information...
markusorngren committed Jan 8, 2018
commit 86ad9d027c04b57822b333ea8659b4072a639e44
View
@@ -0,0 +1,44 @@
# create services
from org.myrobotlab.service import Arduino
from org.myrobotlab.service import Servo
from org.myrobotlab.service import Runtime
python = Runtime.start("python", "Python")
keyboard = Runtime.start("keyboard", "Keyboard")
python.subscribe("keyboard", "publishMouseMoved")
servoPin = 3
servo2Pin = 4
comPort = "COM10"
# start the service
arduino = Runtime.start("arduino","Arduino")
servo01 = Runtime.start("servo01","Servo")
servo02 = Runtime.start("servo02","Servo")
arduino.connect(comPort)
servo01.setMinMax(0, 180)
servo01.attach(arduino.getName(), servoPin)
servo01.map(0,180,180,0)
#servo01.setSpeed(1.0) # set speed to 100% of full speed
servo02.setMinMax(0, 180)
servo02.attach(arduino.getName(), servo2Pin)
servo02.map(0,180,180,0)
#servo02.setSpeed(1.0) # set speed to 100% of full speed
# non blocking event example
keyboard.addKeyListener(python);
def onKey(key):
print ("you pressed ", key)
def onMouseMoved(mouseEvent):
x = mouseEvent.pos.x / 10
x = ("%.0f"%x)
y = mouseEvent.pos.y / 5.6
y = ("%.0f"%y)
print ("x ", x, " y ", y)
servo01.moveTo(int(x))
servo02.moveTo(int(y))
ProTip! Use n and p to navigate between commits in a pull request.