当前位置: 首页>>代码示例>>Python>>正文


Python Arduino.servo_config方法代码示例

本文整理汇总了Python中pyfirmata.Arduino.servo_config方法的典型用法代码示例。如果您正苦于以下问题:Python Arduino.servo_config方法的具体用法?Python Arduino.servo_config怎么用?Python Arduino.servo_config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyfirmata.Arduino的用法示例。


在下文中一共展示了Arduino.servo_config方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: firmata_servo

# 需要导入模块: from pyfirmata import Arduino [as 别名]
# 或者: from pyfirmata.Arduino import servo_config [as 别名]

#.........这里部分代码省略.........
		return RTC.RTC_OK
	
	#	##
	#	#
	#	# The shutdown action when ExecutionContext stop
	#	# former rtc_stopping_entry()
	#	#
	#	# @param ec_id target ExecutionContext Id
	#	#
	#	# @return RTC::ReturnCode_t
	#	#
	#	#
	#def onShutdown(self, ec_id):
	#
	#	return RTC.RTC_OK
	
	#	##
	#	#
	#	# The activated action (Active state entry action)
	#	# former rtc_active_entry()
	#	#
	#	# @param ec_id target ExecutionContext Id
	#	# 
	#	# @return RTC::ReturnCode_t
	#	#
	#	#
	def onActivated(self, ec_id):
		print "onActivated Begin"
		pinNumber = [3, 5, 6, 7, 11]
		self.pin = [None, None, None, None, None]
		try:
			self.board = Arduino(self._com_port[0])
			for i in range(5):
				self.board.servo_config(pinNumber[i], angle=90)
				# Caution: Don't use board.get_pin('d:*:s') as it calls servo_config method with angle=0, which damages your servo.
				self.pin[i] = self.board.digital[pinNumber[i]]
			print "onActivated End"
		except Exception as e:
			print "some errors %s" % str(e)
		self.pin[0].write(80)
		return RTC.RTC_OK
	
	#	##
	#	#
	#	# The deactivated action (Active state exit action)
	#	# former rtc_active_exit()
	#	#
	#	# @param ec_id target ExecutionContext Id
	#	#
	#	# @return RTC::ReturnCode_t
	#	#
	#	#
	#def onDeactivated(self, ec_id):
	#
	#	return RTC.RTC_OK
	
	#	##
	#	#
	#	# The execution action that is invoked periodically
	#	# former rtc_active_do()
	#	#
	#	# @param ec_id target ExecutionContext Id
	#	#
	#	# @return RTC::ReturnCode_t
	#	#
	#	#
开发者ID:thorikawa,项目名称:rtc-johnny-five,代码行数:70,代码来源:firmata_servo.py

示例2: Arduino

# 需要导入模块: from pyfirmata import Arduino [as 别名]
# 或者: from pyfirmata.Arduino import servo_config [as 别名]
### Values for motor direction
FORWARD = 1
BACKWARD = 2
BRAKE = None # These don't work.
RELEASE = None

clients = []

yun = Arduino('/dev/ttyATH0', baudrate=115200)
s = yun.get_shield()
m1 = s.get_motor(1)
m2 = s.get_motor(2)
m1.dir, m2.dir = FORWARD, FORWARD
m1.spd, m2.spd = 0,0
yun.servo_config(9);
yun.servo_config(10);
yun.digital[10].write(60); # Start it at a different angle, so it can move opposite the other servo

def butane_on():
    yun.digital[9].write(60);
    yun.digital[10].write(0);

def butane_off():
    yun.digital[9].write(0);
    yun.digital[10].write(60);

def retrieve(client,value):
    client.send(value)

### Class to handle websocket connections
开发者ID:jpzg,项目名称:YunRobot,代码行数:32,代码来源:linino.py


注:本文中的pyfirmata.Arduino.servo_config方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。