Exemple #1
0
def setServoAngle(s, pwm, pwmNum=15):
    sp = ((SERVO_LEFT + SERVO_RIGHT) / 2) + s * (SERVO_LEFT - SERVO_RIGHT) / 2
    accel.adjustPwmOnTime(pwm, pwmNum, PWM_HZ, sp, 0.4)
Exemple #2
0
      if y >= 2**15:
         y = y - 2**16
      #x = magField.reverseByteOrder(magField.readU16(0x3))
      #y = magField.reverseByteOrder(magField.readU16(0x7))
      #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)