singing animatronic - Raspberry Pi Forums


so far basic script makes servo move left middle right
need way setup timing bare in mind im python newb.

(something wait 1.5 move left, wait 2.0 move right)

code: select all

import rpi.gpio gpio import time gpio.setmode(gpio.board) gpio.setup (11, gpio.out) frequencyhertz = 50 pwm = gpio.pwm(11, frequencyhertz) leftposition = 0.75 rightposition = 2.5 middleposition = (rightposition - leftposition) / 2 + leftposition  positionlist = [leftposition, middleposition, rightposition, middleposition]  mspercycle = 1000 / frequencyhertz in range(3):         position in positionlist:                 dutycyclepercentage = position * 100 / mspercycle                 print "position: " + str(position)                 print "duty cycle: " + str(dutycyclepercentage) + "%"                 print ""                 pwm.start(dutycyclepercentage)                 time.sleep(.5) pwm.stop() gpio.cleanup() 
need little need change .



raspberrypi



Comments

Popular posts from this blog

opencv3, tbb and rasp pi 2 - Raspberry Pi Forums

small ethernet problem - Raspberry Pi Forums

Multithumb configuration params not working? - Joomla! Forum - community, help and support