X-Git-Url: https://vault307.fbx.one/gitweb/Sensory_Wall.git/blobdiff_plain/4f2661a48a227c4ae660130b50149c481f1e9c0c..refs/heads/master:/distanceTest.py diff --git a/distanceTest.py b/distanceTest.py index 1a3909f..dcda41a 100644 --- a/distanceTest.py +++ b/distanceTest.py @@ -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)