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


Python PyMata.get_sonar_data方法代码示例

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


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

示例1: PyMata

# 需要导入模块: from PyMata.pymata import PyMata [as 别名]
# 或者: from PyMata.pymata.PyMata import get_sonar_data [as 别名]
from PyMata.pymata import PyMata


# create a PyMata instance
board = PyMata("/dev/ttyACM0", verbose=True)


# you may need to press ctrl c twice
def signal_handler(sig, frame):
    print('You pressed Ctrl+C')
    if board is not None:
        board.reset()
        board.close()
    sys.exit(0)

signal.signal(signal.SIGINT, signal_handler)

# Configure the trigger and echo pins
board.sonar_config(12, 12)

time.sleep(1)

# Create a forever loop that will print out the sonar data for the PING device

while 1:
    data = board.get_sonar_data()
    print(str(data[2]) + ' centimeters')
    time.sleep(.2)

开发者ID:cero2k6,项目名称:PyMata,代码行数:30,代码来源:ping_config_and_read.py

示例2: range

# 需要导入模块: from PyMata.pymata import PyMata [as 别名]
# 或者: from PyMata.pymata.PyMata import get_sonar_data [as 别名]
firmata.set_pin_mode(52,firmata.OUTPUT,firmata.DIGITAL)
firmata.set_pin_mode(53,firmata.OUTPUT,firmata.DIGITAL)

# configure 4 pins for 4 SONAR modules
firmata.sonar_config(6,6)
time.sleep(.1)
firmata.sonar_config(7,7)
time.sleep(.1)
firmata.sonar_config(37,37)
time.sleep(.1)
firmata.sonar_config(39,39)
time.sleep(1)

# create a forever loop that will sequentially turn on all LEDS,
# then print out the sonar data for the 4 PING devices
# then sequentially turns off all LEDS and print PING data again
print firmata.get_digital_response_table()
while 1:
    for i in range(46,54):
        time.sleep(.1)
        firmata.digital_write(i, 1)
        print firmata.get_sonar_data()

    for i in range(46,54):
        time.sleep(.1)
        firmata.digital_write(i, 0)
        print firmata.get_sonar_data()



开发者ID:Haobot,项目名称:PyMata,代码行数:29,代码来源:pymata_ping_config_and_read.py


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