Exemplo n.º 1
0
def setMotorSpeed(sp, pwm, pwmPair=[0, 1]):
    if sp == 1:
        accel.adjustPwmDuty(pwm, pwmPair[0], 0.5, 0.0, 1)
        accel.adjustPwmDuty(pwm, pwmPair[1], 0.5, 0.0, 0)
    if sp == -1:
        accel.adjustPwmDuty(pwm, pwmPair[0], 0.5, 0.0, 0)
        accel.adjustPwmDuty(pwm, pwmPair[1], 0.5, 0.0, 1)
    elif sp > 0:
        accel.adjustPwmDuty(pwm, pwmPair[0], sp, 0.0, 2)
        accel.adjustPwmDuty(pwm, pwmPair[1], sp, 0.0, 0)
    elif sp < 0:
        accel.adjustPwmDuty(pwm, pwmPair[0], abs(sp), 0.0, 0)
        accel.adjustPwmDuty(pwm, pwmPair[1], abs(sp), 0.0, 2)
    else:
        accel.adjustPwmDuty(pwm, pwmPair[0], 0.5, 0.0, 1)
        accel.adjustPwmDuty(pwm, pwmPair[1], 0.5, 0.0, 1)
Exemplo n.º 2
0
def setLightIntensity(sp, pwm, pwmNum=8):
    if sp <= 1 and sp >= 0:
        accel.adjustPwmDuty(pwm, pwmNum, sp, 0.0)
Exemplo n.º 3
0
      #z = magField.reverseByteOrder(magField.readU16(0x5))
      print "%s %s %s %s" % (t, x, y, z)

      a = linAccel.readList(0x28,1)
      b = linAccel.readList(0x29,1)
      c = linAccel.readList(0x28,2)
      print "  %s %s %s" % (a,b,c)
      #time.sleep(1)

      
s = 2.4 - (2.4-0.5)/2
accel.adjustPwmOnTime(pwm,15,PWM_HZ,s,0.4)
print "middle?"
#Stime.sleep(3)
sp = 0.1
accel.adjustPwmDuty(pwm,0,sp,0.0,0)
accel.adjustPwmDuty(pwm,1,sp,0.0,2)

while sp > -1.0 and sp < 1.0:
   if sp > 0:
      accel.adjustPwmDuty(pwm,0,sp,0.0,2)
      accel.adjustPwmDuty(pwm,1,sp,0.0,0)
   elif sp < 0:
      accel.adjustPwmDuty(pwm,0,abs(sp),0.0,0)
      accel.adjustPwmDuty(pwm,1,abs(sp),0.0,2)
   else:
      accel.adjustPwmDuty(pwm,0,0.5,0.0,1)
      accel.adjustPwmDuty(pwm,1,0.5,0.0,1)
   sp = input("Enter Speed: ")
accel.adjustPwmDuty(pwm,0,0.5,0.0,1)
accel.adjustPwmDuty(pwm,1,0.5,0.0,1)