Ejemplo n.º 1
0
def init():
    # servoMin = 150  # Min pulse length out of 4096
    # servoMax = 600  # Max pulse length out of 4096
    pwm = PWM(0x40)
    # pwm = PWM(0x40, debug=True)
    pwm.setPWMFreq(60)  # Set frequency to 60 Hz
    # pwm.setPWM(0, 0, 450)   #medium
    return pwm
def init():
	#servoMin = 150  # Min pulse length out of 4096
	#servoMax = 600  # Max pulse length out of 4096
	pwm = PWM(0x40)
	#pwm = PWM(0x40, debug=True)
	pwm.setPWMFreq(60)                      # Set frequency to 60 Hz
	#pwm.setPWM(0, 0, 450)   #medium
	return pwm
Ejemplo n.º 3
0
def main():
    print("i2c test")
    pwm = PWM(address=0x40, debug=True)
#!/usr/bin/python
from Sunfounder_PWM_Servo_Driver import PWM
import time

# ===========================================================================
# Example Code
# ===========================================================================

# Initialise the PWM device using the default address
#pwm = PWM(0x40)
# Note if you'd like more debug output you can instead run:
pwm = PWM(0x40, debug=True)

servoMin = 150  # Min pulse length out of 4096
servoMax = 600  # Max pulse length out of 4096

def setServoPulse(channel, pulse):
	pulseLength = 1000000                   # 1,000,000 us per second
	pulseLength /= 60                       # 60 Hz
	print "%d us per period" % pulseLength
	pulseLength /= 4096                     # 12 bits of resolution
	print "%d us per bit" % pulseLength
	pulse *= 1000
	pulse /= pulseLength
	pwm.setPWM(channel, 0, pulse)

pwm.setPWMFreq(60)                        # Set frequency to 60 Hz

while (True):
	pwm.setPWM(3, 0, 375)
	time.sleep(1)
Ejemplo n.º 5
0
#!/usr/bin/python
from Sunfounder_PWM_Servo_Driver import PWM
import time

# ===========================================================================
# Example Code
# ===========================================================================

# Initialise the PWM device using the default address
#pwm = PWM(0x40)
# Note if you'd like more debug output you can instead run:
pwm = PWM(0x40, debug=True)

servoMin = 150  # Min pulse length out of 4096
servoMax = 600  # Max pulse length out of 4096


def setServoPulse(channel, pulse):
    pulseLength = 1000000  # 1,000,000 us per second
    pulseLength /= 5  # 50 Hz
    print("%d us per period" % pulseLength)
    pulseLength /= 4096  # 12 bits of resolution
    print("%d us per bit" % pulseLength)
    pulse *= 1000
    pulse /= pulseLength
    pwm.setPWM(channel, 0, int(pulse))


def setServo(position):
    servoMin = 105
    servoMax = 525
Ejemplo n.º 6
0
#!/usr/bin/python
import time
from Sunfounder_PWM_Servo_Driver import PWM

pwm = PWM(0x40)
pwm.setPWMFreq(60)

# Min found around 150
# Max found around 700
servoMin = 150
servoMax = 700
servoMid = servoMin + (servoMax - servoMin) / 2

debug = False

mouthChannel = 0
headChannel = 4


def log(string):
    if debug:
        print string
    return


def setServoValue(channel, value):
    pwm.setPWM(channel, 0, value)
    log("Setting channel " + str(channel) + " to " + str(value))
    return

Ejemplo n.º 7
0
#!/usr/bin/python
from Sunfounder_PWM_Servo_Driver import PWM
import time

# ===========================================================================
# Example Code
# ===========================================================================

# Initialise the PWM device using the default address
#pwm = PWM(0x40)
# Note if you'd like more debug output you can instead run:
pwm = PWM(0x40, debug=True)

servoMin = 150  # Min pulse length out of 4096
servoMax = 600  # Max pulse length out of 4096


def setServoPulse(channel, pulse):
    pulseLength = 1000000  # 1,000,000 us per second
    pulseLength /= 60  # 60 Hz
    print "%d us per period" % pulseLength
    pulseLength /= 4096  # 12 bits of resolution
    print "%d us per bit" % pulseLength
    pulse *= 1000
    pulse /= pulseLength
    pwm.setPWM(channel, 0, pulse)


pwm.setPWMFreq(60)  # Set frequency to 60 Hz

while (True):
Ejemplo n.º 8
0
#!/usr/bin/python
import time
from Sunfounder_PWM_Servo_Driver import PWM

pwm = PWM(0x40, True)
pwm.setPWMFreq(60)


# Min found around 150
# Max found around 700
servoMin = 150
servoMax = 700



print "Hello, servo-world"

while (True):
  # Change speed of continuous servo on channel O
  pwm.setPWM(0, 0, servoMin)
  time.sleep(1)
  pwm.setPWM(0, 0, servoMax)
  time.sleep(1)
  print "Looping!"