Simple test

Ensure your device works with this simple test.

examples/hcsr04_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4import time
 5
 6import board
 7
 8import adafruit_hcsr04
 9
10sonar = adafruit_hcsr04.HCSR04(trigger_pin=board.D5, echo_pin=board.D6)
11
12while True:
13    try:
14        print((sonar.distance,))
15    except RuntimeError:
16        print("Retrying!")
17    time.sleep(0.1)