本文整理汇总了Python中pyfirmata.Arduino.readAnalogPin方法的典型用法代码示例。如果您正苦于以下问题:Python Arduino.readAnalogPin方法的具体用法?Python Arduino.readAnalogPin怎么用?Python Arduino.readAnalogPin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyfirmata.Arduino
的用法示例。
在下文中一共展示了Arduino.readAnalogPin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Uarm
# 需要导入模块: from pyfirmata import Arduino [as 别名]
# 或者: from pyfirmata.Arduino import readAnalogPin [as 别名]
#.........这里部分代码省略.........
self.servo_right.write(self.angleConstrain(Angle+ self.readServoOffset(servo_number)))
elif servo_number == 4:
self.servo_end.write(self.angleConstrain(Angle+ self.readServoOffset(servo_number)))
else:
return
def writeAngle(self,servo_1,servo_2,servo_3,servo_4):
servoAngles = {}
servoAngles[1] = servo_1 + self.readServoOffset(1)
servoAngles[2] = servo_2 + self.readServoOffset(2)
servoAngles[3] = servo_3 + self.readServoOffset(3)
servoAngles[4] = servo_4 + self.readServoOffset(4)
self.servo_base.write(self.angleConstrain(servoAngles[1]))
self.servo_left.write(self.angleConstrain(servoAngles[2]))
self.servo_right.write(self.angleConstrain(servoAngles[3]))
self.servo_end.write(self.angleConstrain(servoAngles[4]))
def writeAngleRaw(self,servo_1,servo_2,servo_3,servo_4):
self.servo_base.write(self.angleConstrain(servo_1))
self.servo_left.write(self.angleConstrain(servo_2))
self.servo_right.write(self.angleConstrain(servo_3))
self.servo_end.write(self.angleConstrain(servo_4))
def readAnalog(self,servo_number):
if servo_number == 1:
for i in range(1,4):
data = self.uarm.readAnalogPin(2)
return data
elif servo_number == 2:
for i in range(1,4):
data = self.uarm.readAnalogPin(0)
return data
elif servo_number == 3:
for i in range(1,4):
data = self.uarm.readAnalogPin(1)
return data
elif servo_number == 4:
for i in range(1,4):
data = self.uarm.readAnalogPin(3)
return data
else:
return
def readServoOffset(self,servo_number):
if servo_number ==1 or servo_number ==2 or servo_number ==3:
addr = self.kAddrOffset + (servo_number - 1)*2
servo_offset = (self.uarm.readEEPROM(addr+1))/10.00
if(self.uarm.readEEPROM(addr) == 0):
servo_offset *= -1
return servo_offset
elif servo_number == 4:
return 0
else:
pass
def readToAngle(self,input_analog,servo_number,tirgger):
addr = self.kAddrAandB + (servo_number-1)*6