diff --git a/garage_door_script.py b/garage_door_script.py index cbd7d75..05f09b2 100644 --- a/garage_door_script.py +++ b/garage_door_script.py @@ -31,6 +31,10 @@ def index(): pulse_end_time = time.time() #Record the time the waves traveled back to the sensor pulse_duration = pulse_end_time - pulse_start_time #Calculate how long it took for the round trip of the waves distance = round(pulse_duration * 17150, 2) #Convert the time it took to centimeters and round to 2 decimals + if distance >= 80: #Check if the distance is less than 80cm (This will depend on the garage) + return 'The garage is closed.' + else: + return 'The garage is open.' if __name__ == '__main__': app.run(host='0.0.0.0') #Run the webserver