I have some code using python that sets up the pins as inputs and was wondering if anyone has had experience with any debounce advantage that using a falling edge may provide. Right now I have resistor pullups on my switches which are soldered and .1 caps to ground on each and 99.9% of the time I don't have a problem -- the switches are scanned in a fast loop (100 milliseconds).
But I also "try" to get a debounce and can sometimes -- but before I test using falling edge instead of just "input", thought I'd ask.
so that's question 1
Also, just trying to get my head around why you can't "configure" the inputs in a setup just once rather than doing each time. What I mean is --
GPIO.setup(3,GPIO.IN) # I get that and yes, I can do that just once and initialize it in my class,
but why is it you can't also ? --
self.var = GPIO.input(3) # I have to include this line in my loop when I scan the inputs (seems kind of redundant)
if self.var == 1:
do this
And -- if I were to change GPIO.input(3) to utilize falling edge it becomes --
GPIO.add_event_detect(3,GPIO.FALLING) # can this be stated once in initialize?
then
GPIO.wait_for_edge(3,GPIO_FALLING,timeout=10) # has to run in the loop also? (wow?)
Hope I'm making sense -- just seems like your asking the cpu to do a lot (over and over again) just to sense an input.
Thanks.