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


Python Arduino.setup方法代码示例

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


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

示例1: Arduino

# 需要导入模块: from arduino import Arduino [as 别名]
# 或者: from arduino.Arduino import setup [as 别名]
    try:
    	b = Arduino('/dev/ttyACM0')
	print "Connected to ttyACM0"
    except:
        b = Arduino('/dev/ttyUSB0')
	print "Connected to ttyUSB0"

master_led_pin = 13
master_servo_pin = 12

slave_connection_pin = 11# In master
slave_led_pin = 13
slave_servo_pin = 12

#declare output pins as a list/tuple
b.setup([master_led_pin], [], [master_servo_pin])
#b.setup([], [], [])
b.setupSlave(0, slave_connection_pin, [slave_led_pin], [], [slave_servo_pin])

pos=1
for i in xrange(18):
     b.setHigh(master_led_pin)
     b.nextCommandAsSlave(0)
     b.setHigh(slave_led_pin)

     time.sleep(0.5)
     b.setLow(master_led_pin)
     b.nextCommandAsSlave(0)
     b.setLow(slave_led_pin)
     time.sleep(0.5) 
     b.nextCommandAsSlave(0)
开发者ID:dmanfly,项目名称:geecon2015,代码行数:33,代码来源:slave_with_servo.py

示例2: Arduino

# 需要导入模块: from arduino import Arduino [as 别名]
# 或者: from arduino.Arduino import setup [as 别名]
	   pins_by_chip[chip]["output"].add(output_pin)
	
master_inputs = [switch.pin for switch in switches]

try:
    b = Arduino('/dev/tty.usbmodem1421')
    print "Connected to usbmodem1421"
except:
    try:
    	b = Arduino('/dev/ttyACM1')
	print "Connected to ttyACM1"
    except:
        b = Arduino('/dev/ttyUSB0')
	print "Connected to ttyUSB0"

b.setup(pins_by_chip[MASTER_CHIP]["output"], master_inputs, pins_by_chip[MASTER_CHIP]["servos"])
#b.setupSlave(SLAVE1_CHIP, SLAVE1_TX, pins_by_chip[SLAVE1_CHIP]["output"], [], pins_by_chip[SLAVE1_CHIP]["output"])
#b.setupSlave(SLAVE2_CHIP, SLAVE2_TX, pins_by_chip[SLAVE2_CHIP]["output"], [], pins_by_chip[SLAVE2_CHIP]["output"])
 
current_scene = None
while (1):
    for switch in switches:
	scene = switch.check_trigger(b)
	if scene:
	    print "New scene!"
	    if current_scene:
		current_scene.destroy(b)
	    time.sleep(0.1)
	    scene.start()
	    current_scene = scene
   
开发者ID:dmanfly,项目名称:geecon2015,代码行数:32,代码来源:instruments.py


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