commit 92f5354e3d313c980293dae534f307dda79ac4ce Author: George_Andreou Date: Sat May 24 03:34:20 2025 +0300 Create repo diff --git a/README.md b/README.md new file mode 100644 index 0000000..6f4d991 --- /dev/null +++ b/README.md @@ -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. \ No newline at end of file diff --git a/sensortest-rally.py b/sensortest-rally.py new file mode 100644 index 0000000..db4178c --- /dev/null +++ b/sensortest-rally.py @@ -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) \ No newline at end of file