I commonly see the following algorithm to read a button in a Pi:
But, does this handle the bouncing with the time.sleep function? I'm looking for the simplest way to debounce a button, as my program is not complex I don't need extensive debouncing routines.
Code:
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.IN,pull_up_down=GPIO.PUD_UP)
while True:
inputValue = GPIO.input(18)
if (inputValue == False):
do something
time.sleep(0.3)