Skip to main content

Ultrasonic

Stemi Shield can be connected to included ultra sonic sensor through adafruit_hcsr04.HCSR04 class on pins board.IO13 and board.IO14 or board.IO15 and board.IO16. Refer to the api here.

Ultrasonic

Example

main.py
import board
from adafruit_hcsr04 import HCSR04

sonar_front = HCSR04(trigger_pin=board.IO14, echo_pin=board.IO13)
sonar_right = HCSR04(trigger_pin=board.IO16, echo_pin=board.IO15)

print(f"{sonar_front.distance:.2f} - {sonar_right.distance:.2f}")