Skip to content

Commit

Permalink
Initial Release
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Nov 2, 2021
1 parent 017174b commit aa51882
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions hcsr04.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/python3

import time
import board
import adafruit_hcsr04

sonar = adafruit_hcsr04.HCSR04(trigger_pin=board.D5, echo_pin=board.D6)

while True:
try:
print("Distance: %.2f cm" % sonar.distance)
except RuntimeError:
print("Retrying!")
time.sleep(0.1)

0 comments on commit aa51882

Please sign in to comment.