-
-
Save CodeNextAdmin/5ad4f2d35a150cb2dc8dc9a58ccb5902 to your computer and use it in GitHub Desktop.
GPIO Zero distance LED blink
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 LED, DistanceSensor | |
from time import sleep | |
# DisanceSensor(echo, trigger) | |
sensor = DistanceSensor(26, 20) | |
led = LED(14) | |
blink_rate = 0 | |
def blink(d): | |
if d < 1.0: | |
led.on() | |
sleep(d) | |
led.off() | |
sleep(d) | |
else: | |
led.off() | |
while True: | |
print(sensor.distance) | |
blink(sensor.distance) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment