Create repository for the folkrace competition.
This commit is contained in:
commit
f705faf83e
3 changed files with 63 additions and 0 deletions
16
sensortest.py
Normal file
16
sensortest.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import time
|
||||
import board
|
||||
import adafruit_hcsr04
|
||||
|
||||
# Set the sensor pins
|
||||
front = adafruit_hcsr04.HCSR04(trigger_pin=board.D12, echo_pin=board.D13)
|
||||
right = adafruit_hcsr04.HCSR04(trigger_pin=board.D10, echo_pin=board.D11)
|
||||
left = adafruit_hcsr04.HCSR04(trigger_pin=board.D8, echo_pin=board.D9)
|
||||
|
||||
while True:
|
||||
try:
|
||||
print("F =", f"{front.distance:.2f}", "|", "L =", f"{left.distance:.2f}", "|", "R =", f"{right.distance:.2f}")
|
||||
|
||||
except RuntimeError:
|
||||
print("Retrying!")
|
||||
time.sleep(0.1)
|
||||
Loading…
Add table
Add a link
Reference in a new issue