格罗夫超声波游侠没有任何反应

问题描述

我正在尝试使用带有raspBerrypi 3b +上的grovePi +帽子的grove Ultrasonic Ranger(v2.0)。 使用“ sudo i2cdetect -y 1”时会检测到该设备,但是,当我运行该程序时,没有任何反应。我没有收到错误,也没有任何显示。好像程序正在运行,但是卡住了,没有发出错误。我正在使用DexterIndustries提供的代码,并将其附加在下面。

#!/usr/bin/env python
#
# grovePi Example for using the grove Ultrasonic Ranger (http://www.seeedstudio.com/wiki/grove_-_Ultras$
#
# The grovePi connects the RaspBerry Pi and grove sensors.  You can learn more about grovePi here:  htt$
#
# Have a question about this example?  Ask on the forums here:  http://forum.dexterindustries.com/c/gro$
#
'''
## License

The MIT License (MIT)

grovePi for the RaspBerry Pi: an open source platform for connecting grove Sensors to the RaspBerry Pi.
copyright (C) 2017  Dexter Industries

Permission is hereby granted,free of charge,to any person obtaining a copy
of this software and associated documentation files (the "Software"),to deal
in the Software without restriction,including without limitation the rights
to use,copy,modify,merge,publish,distribute,sublicense,and/or sell
copies of the Software,and to permit persons to whom the Software is
furnished to do so,subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS",WITHOUT WARRANTY OF ANY KIND,EXPRESS OR
IMPLIED,INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,fitness FOR A PARTIculaR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR copYRIGHT HOLDERS BE LIABLE FOR ANY CLaim,damAGES OR OTHER
LIABILITY,WHETHER IN AN ACTION OF CONTRACT,TORT OR OTHERWISE,ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
'''

import grovepi
import time

# set I2C to use the hardware bus
grovepi.set_bus("RPI_1")

# Connect the grove Ultrasonic Ranger to digital port D4
# SIG,NC,VCC,GND
ultrasonic_ranger = 4

while True:
    try:
        # Read distance value from Ultrasonic
        print(grovepi.ultrasonicRead(ultrasonic_ranger))

    except Exception as e:
        print ("Error:{}".format(e))

    time.sleep(0.1) # don't overload the i2c bus

任何帮助将不胜感激。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)