Browse Source

added calibrate and calculate position function

w.mueller 3 years ago
parent
commit
fbf05f78b4
1 changed files with 21 additions and 1 deletions
  1. 21 1
      raspberry-pi/main.py

+ 21 - 1
raspberry-pi/main.py

@@ -1,3 +1,23 @@
-from sensors import *
+import sensors
+import time
+
+distance = 450 #in mm
+
+def main():
+    ac_sensor = sensors.AcusticSensor()
+    ac_sensor.start()
+    ac_sensor.calibrate(distance)
+    try:
+        while True:
+            x,y = ac_sensor.calculate_position()
+            print(x,y)
+            time.sleep(2)
+    except KeyboardInterrupt:
+        print("exit")
+    except Exception as e:
+        print("Error: ",e)
+
+main()
+