old_contents: # This part will execute every time the left eye changes position
  # and will make the right eye servo move in sync with the left
  # This also allows for a point to adjust any offset between the eyes
  # and also the posibility to have the servos move in opposite direction
  def onServoEvent(pos):
  	eyeXR.moveTo(pos)
  # Get the handle to the Python service
  python = Runtime.getService("python")
  # Start the Arduino service and connect to it
  arduino = Runtime.createAndStart("arduino","Arduino")
  arduino.connect("COM5")
  # Start the left eye and set it's rest position
  # Left eye
  eyeXL = Runtime.createAndStart("eyeXLeft","Servo")
  eyeXL.setRest(90)
  eyeXL.attach(arduino,10)
  eyeXL.rest()
  # Start the right eye and set it's rst position
  # Right Eye
  eyeXR = Runtime.createAndStart("eyeXRight","Servo")
  eyeXR.setRest(90)
  eyeXR.attach(arduino,11)
  eyeXR.rest()
  # Add python as a listener to changes of servo positions
  # and enable the pblishing of servoevents
  eyeXL.addServoEventListener(python)
  eyeXL.eventsEnabled(True)
  
new_contents: # A script to show how to syncronize two servos using the publish / subscribe pattern
  # Works from version 1.0.1739
  speech = Runtime.createAndStart("Speech","AcapelaSpeech")
  speech.setVoice("Will")
  speech.speakBlocking("Startting Arduino")
  # Minimal script to syncronize 2 servos
  arduino = Runtime.createAndStart("Arduino","Arduino")
  arduino.connect("/dev/ttyACM0")
  # Connect the left eye
  leftEyeX = Runtime.createAndStart("LeftEyeX","Servo")
  leftEyeX.attach(arduino,10)
  # Remap the left eye since it is 10 degrees offset to the right
  leftEyeX.map(0,180,-10,170)
  # Connect the right eye
  rightEyeX = Runtime.createAndStart("RightEyeX","Servo")
  rightEyeX.setMinMax(60,120)
  rightEyeX.setRest(90)
  rightEyeX.attach(arduino,11)
  rightEyeX.rest()
  # Make the left eye follow the right
  rightEyeX.addServoEventListener(leftEyeX)
  rightEyeX.eventsEnabled(True)
  def lookRight():
  	rightEyeX.moveTo(120)
  	speech.speakBlocking("Looking right")
  def lookLeft():
  	rightEyeX.moveTo(60)
  	speech.speakBlocking("Looking left")
  def lookForward():
  	rightEyeX.rest()
  	speech.speakBlocking("Looking forward")
  lookRight()
  lookLeft()
  lookForward()
  
subject: Update SyncServos.py