Create repo
This commit is contained in:
commit
92f5354e3d
2 changed files with 15 additions and 0 deletions
1
README.md
Normal file
1
README.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
A repository for our robot in the MRC Robotex Cyprus Rally competition. The robot uses the motor2040 controller and 2 micrometal gearmotors, with encoders attached in order to measure the distance travelled.
|
||||
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