modules.ultrasonic (ultrasonic ranging module)
Grove-Ultrasonic Ranger (ultrasonic ranging module), only a single data cable is required
Construction method ultrasonic(gpiohs)
Parameters
gpiohs
: gpiohs number, you need to usefm
to register the pin first, for example
from fpioa_manager import *
from modules import ultrasonic
fm.register(board_info.D[6], fm.fpioa.GPIOHS0, force = True)
device = ultrasonic(fm.fpioa.GPIOHS0)
return value
Return object
Method measure(unit, timeout)
Parameters
unit
: unit, take the value in the following constanttimeout
: timeout time, in microseconds (us)
Constant
ultrasonic.UNIT_CM
The unit of the returned distance, cm
ultrasonic.UNIT_INCH
The unit of the returned distance, feet