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


Python Arduino.setAngle方法代码示例

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


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

示例1: xrange

# 需要导入模块: from arduino import Arduino [as 别名]
# 或者: from arduino.Arduino import setAngle [as 别名]
#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)
     b.setAngle(slave_servo_pin,pos)
     pos +=10
     print i
     print pos

"""     
     b.setAngle(master_servo_pin, i * 10)
     b.nextCommandAsSlave(0)
     b.setAngle(slave_servo_pin, i * 10)    
b.close()
""" 

开发者ID:dmanfly,项目名称:geecon2015,代码行数:30,代码来源:slave_with_servo.py

示例2: if

# 需要导入模块: from arduino import Arduino [as 别名]
# 或者: from arduino.Arduino import setAngle [as 别名]
# time.sleep(1)
pos = 1
d = 1
s = 20
while 1:
    button = b.digitalRead(8)

    # if (button!=u'0\r'):
    #     print "["+button+"]" + str(pos)
    #     b.setAngle(12,pos)
    #     pos += 4* d
    #     time.sleep(0.001)
    #     if pos>180 or pos<= 0:
    #         d=-1*d
    if button != u"0\r":
        b.setAngle(12, 90)
        time.sleep(1)
        b.setAngle(12, 0)
        time.sleep(1)

# for pos in range (0,180,5):
#     b.setAngle(12,pos)
#     time.sleep(0.030)
# for pos in range (180,0,-5):
#     b.setAngle(12,pos)
#     time.sleep(0.030)


b.close()
开发者ID:dmanfly,项目名称:geecon2015,代码行数:31,代码来源:click.py

示例3: xrange

# 需要导入模块: from arduino import Arduino [as 别名]
# 或者: from arduino.Arduino import setAngle [as 别名]
#servo2 = 12
#b.output([])
#b.input([])
#b.servos([servo1, servo2])   
# for i in xrange(18):
#     # b.setHigh(pin)
#     # time.sleep(1)
#     # print b.getState(pin)
#     # b.setLow(pin)
#     # print b.getState(pin)
#     # time.sleep(1)
#     an = 3.14/180 * i * 10
#     an = i*10
#     print an
#     b.setAngle(12,an)
    
    # time.sleep(1)
for i in xrange(10):
    for pos in range (0,180,5):
        b.setAngle(servo1,pos)
        b.setAngle(servo2,pos)
        time.sleep(0.030)
    for pos in range (180,0,-5):
        b.setAngle(servo1,pos)
        b.setAngle(servo2,pos)
        time.sleep(0.030)


b.close()

开发者ID:dmanfly,项目名称:geecon2015,代码行数:31,代码来源:sample_blink.py


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