import RPi.GPIO as GPIO
import time

channel = 21   #GPIO pin 21 Rpi pin 40
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(channel, GPIO.IN)

def callback(channel):
    if GPIO.input(channel):
        print("No moisture Detected")
    else:
        print("moisture Detected")

GPIO.add_event_detect(channel, GPIO.BOTH, bouncetime =300)
GPIO.add_event_callback(channel, callback)


while True:
    time.sleep(1)
