repository to manage all files related to the makeathon farm bot project (Software + Documentation).
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

earth_hum.py 375B

12345678910111213141516171819
  1. import RPi.GPIO as GPIO
  2. import time
  3. chanel = 21
  4. GPIO.setmode(GPIO.BCM)
  5. GPIO.setup(chanel, GPIO.IN)
  6. def callback(chanel):
  7. if GPIO.input(chanel):
  8. print("No water detected")
  9. else:
  10. print("Water detected")
  11. print(GPIO.input(chanel))
  12. GPIO.add_event_detect(chanel, GPIO.BOTH, bouncetime=300)
  13. GPIO.add_event_callback(chanel, callback)
  14. callback(chanel)