Ultrasound

The servo assembly has support for measuring distances using ultrasound sensors.

Reading a distance

Assuming you wired the ultrasound sensor’s trigger pin to digital pin 6 on the servo assembly, and the echo pin to pin 7, you can query the distance from the sensor using:

r.servo_board.read_ultrasound(6, 7)
>>> 0.524

The returned distance is in metres.