diff --git a/main.py b/main.py index 957a874..75dcfe6 100644 --- a/main.py +++ b/main.py @@ -18,9 +18,6 @@ except ImportError: sys.path.append('./SDL_Adafruit_ADS1x15') import SDL_Adafruit_ADS1x15 -GPIO.setmode(GPIO.BOARD) -GPIO.setwarnings(False) - def debug_print(message: str): now = datetime.now() current_time = now.strftime("%H:%M:%S") @@ -43,12 +40,14 @@ def relay_controller(pin: int, status: str): error_print("Unknown status for relay ("+status+")") #ultrasonic -GPIO_TRIGGER = 18 -GPIO_ECHO = 24 -GPIO.setup(GPIO_TRIGGER, GPIO.OUT) -GPIO.setup(GPIO_ECHO, GPIO.IN) def get_water_level(): + GPIO.setmode(GPIO.BOARD) + GPIO.setwarnings(False) + GPIO_TRIGGER = 18 + GPIO_ECHO = 24 + GPIO.setup(GPIO_TRIGGER, GPIO.OUT) + GPIO.setup(GPIO_ECHO, GPIO.IN) GPIO.output(GPIO_TRIGGER, True) time.sleep(0.00001) GPIO.output(GPIO_TRIGGER, False)