Created
September 10, 2021 15:23
-
-
Save chainhead/1cc7b20a6e825d682a8a22d72ce3169a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/python | |
import RPi.GPIO as GPIO | |
import time | |
#GPIO SETUP | |
channel = 21 | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setup(channel, GPIO.IN) | |
def moisture_detect(channel): | |
if GPIO.input(channel): | |
print "No moisture detected" | |
else: | |
print "Moisture Detected!" | |
GPIO.add_event_detect(channel, GPIO.BOTH, callback=moisture_detect) | |
# infinite loop | |
while True: | |
print "loop" | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment