Created
March 2, 2017 02:19
-
-
Save anonymous/fdf5c09391dee8ba5102f64a81bb8bbf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gpiozero import DistanceSensor | |
from time import sleep | |
from gpiozero import LED | |
from gpiozero import pause | |
Requirement = input('Input required distance in [cm]: ') | |
led = LED(5) | |
sensor = DistanceSensor(echo=18, trigger=17) | |
while True: | |
print('Distance: ', sensor.distance * 100) | |
DistanceRead = sensor.distance * 100 | |
if DistanceRead == Requirement: | |
led.on() | |
else led.off() | |
pause() | |
sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment