On 06/18/2015 01:35 PM, Oscar Benjamin wrote: > I use the following. I found in testing that when you push the button it > prints 'Button pressed' 10 times a second (in actual use it calls poweroff > so I guess bounce isn't an issue there). Is there some reason it needs to > be cleverer in this case?
Yes, that would be expected, given your code has a while loop that never exits. Just curious what you expect the code to do that it's not doing. You are probably right that debouncing isn't important in your application. So just add your poweroff command after the print() statement, and break out of the loop: ... while True: time.sleep(0.1) if not GPIO.input(PIN_NUM): print('Button pressed') # run shutdown command here os.system('/usr/sbin/shutdown') break -- https://mail.python.org/mailman/listinfo/python-list