import utime
import us100
+<<<<<<< HEAD
uart = machine.UART(0)
sensor = us100.US100UART(uart)
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)