Import the servo and serial port libraries


In [70]:
import serial
import Servo
import time

In [3]:
from IPython.html.widgets import interact


:0: FutureWarning: IPython widgets are experimental and may change in the future.

Open the serial port


In [4]:
sp = serial.Serial("/dev/ttyUSB0", 19200)

Create a servo object


In [44]:
a = Servo.Servo(sp, dir = 'a')
b = Servo.Servo(sp, dir = 'b')
c = Servo.Servo(sp, dir = 'c')

Move the servo for testing. Change the pos value


In [38]:
a.pos = 60
b.pos = -60

Interactive widget for moving the servo


In [69]:
w1 = interact(a.set_pos, pos = (-90, 90))
w2 = interact(b.set_pos, pos = (-90, 90))
w3 = interact(c.set_pos, pos = (-90, 90))

In [68]:
for i in range(2):
    c.pos = -60
    time.sleep(1)
    c.pos = 20
    time.sleep(1)

In [ ]: