Create repo
This commit is contained in:
commit
92f5354e3d
2 changed files with 15 additions and 0 deletions
14
sensortest-rally.py
Normal file
14
sensortest-rally.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import time
|
||||
import board
|
||||
import adafruit_hcsr04
|
||||
|
||||
# Set the sensor pins
|
||||
sonar = adafruit_hcsr04.HCSR04(trigger_pin=board.TRIG, echo_pin=board.ECHO)
|
||||
|
||||
while True:
|
||||
try:
|
||||
print(f"{sonar.distance:.2f}")
|
||||
|
||||
except RuntimeError:
|
||||
print("Retrying!")
|
||||
time.sleep(0.1)
|
||||
Loading…
Add table
Add a link
Reference in a new issue