Last active
October 18, 2021 22:06
-
-
Save CodeNextPaco/b53d1c04c49806ca1ec6b78877f1ca50 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