]> vault307.fbx.one Git - Sensory_Wall.git/blobdiff - distanceTest.py
more sensory wall projects
[Sensory_Wall.git] / distanceTest.py
index 1a3909fa79a624a132476bdcbb9c35115129bf3d..dcda41a5b765b03a994398a992c488ebbfc01bd5 100644 (file)
@@ -2,6 +2,7 @@ import machine
 import utime
 import us100
 
+<<<<<<< HEAD
 uart = machine.UART(0)
 sensor = us100.US100UART(uart)
 
@@ -9,3 +10,58 @@ Ygem=machine.Pin(10,machine.Pin.OUT)
 Bgem=machine.Pin(16,machine.Pin.OUT)
 plant=machine.Pin(18,machne.Pin.OUT)
 
+=======
+uart = machine.UART(1)
+sensor = us100.US100UART(uart)
+
+distance=0
+
+Ygem=machine.Pin(10,machine.Pin.OUT)
+Bgem=machine.Pin(16,machine.Pin.OUT)
+plant=machine.Pin(18,machine.Pin.OUT)
+
+Ygem.off();Bgem.off();plant.off()
+
+def measure():
+    global distance
+    distance=sensor.distance()
+    return distance
+    
+def analyze():
+    if distance <=500 and distance>=350:
+        Ygem.on()
+        Bgem.off()
+        plant.off()
+        return
+    elif distance <=350 and distance >=150:
+        plant.on()
+        Ygem.off()
+        return
+    elif distance <=150 and distance >75:
+        Bgem.on()
+        plant.off()
+        Ygem.on()
+        return
+    elif distance <=75:
+        Bgem.off()
+        plant.on()
+        Ygem.on()
+        return
+    else:
+        Bgem.off()
+        plant.off()
+        Ygem.off()
+        return
+
+while True:
+    try:
+        measure()
+        print(distance)
+        analyze()
+        utime.sleep_ms(50)
+    except Exception: #catches error if sensor is covered, simply passes that cycle
+        print("HEY BOSS")
+        pass
+if KeyboardInterrupt: 
+    pass
+>>>>>>> 2af4f5c (more sensory wall projects)