User Tools

Site Tools


motors-test-2

Warning: Use of undefined constant PREG_PATTERN_VALID_LANGUAGE - assumed 'PREG_PATTERN_VALID_LANGUAGE' (this will throw an Error in a future version of PHP) in /var/www/kucjica/emperors-wiki/inc/parser/xhtml.php on line 633

Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in /var/www/kucjica/emperors-wiki/inc/parser/xhtml.php on line 633

short script to test te sync between two linear actuators; they move from their minimum position to maximum and back

from arduino import Arduino, Servo

import glob, time

#get the active port
portz=glob.glob("/dev/ttyUSB*")[0]
print portz

#specify the port as an argument
my_board = Arduino(portz)

#declare output pins as a list/tuple
my_board.output([9,10])
linear_one=my_board.attachServo(9)
linear_two=my_board.attachServo(10)

#perform operations
linear_one.write(75)
linear_two.write(89)
print "putting servos to sleep. positions: 40, 80"
time.sleep(5)

positions = {0:[(72,87)],1:[(73,88)],2:[(74,88)],3:[(75,89)],4:[(76,90)],5:[(77,90)],6:[(78,91)],7:[(82,92)],8:[(88,95)],9:[(93,98)],10:[(100,101)],11:[(110,108)],12:[(114,109)],13:[(120,111)],14:[(124,113)],15:[(125,114)],16:[(128,115)],17:[(129,116)],18:[(130,117)],19:[(132,118)],20:[(135,119)],21:[(137,120)],22:[(139,121)]}

key=0
while(key<len(positions)):
    print positions[key]
    linear_one.write(positions[key][0][0])
    linear_two.write(positions[key][0][1])
    time.sleep(1)
    key+=1


linear_one.write(positions[0][0][0])
linear_two.write(positions[0][0][1])
time.sleep(5)
motors-test-2.txt · Last modified: 2012/09/24 21:37 by 81.10.185.142