I have a python script running as a service on Raspbian Jessie that watches for a button being pressed and lights an LED when it is done. Initially everything works as designed, however I have found that once the process has been running for several hours at seemingly random intervals the GPIO pin that is attached to the button is pulled down and acts if the button is pressed. What is unexpected is that when I press the button it then acts like it is not pressed (this wasn't expected as I assumed there was a short). The button is wired to ground and I have a 10K pull-up resistor in place on both the LED and the button.

Script is wired like this (LED to 25, button to 24):

import RPi.GPIO as GPIO
GPIO.setup(25, GPIO.OUT)  
GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_UP)

def button(channel):  
    if GPIO.input(24):
        print "rising edge detected on port 24"
        print "falling edge detected on port 24"

GPIO.add_event_detect(24, GPIO.BOTH, callback=button, bouncetime=300) 

while 1:



simulate this circuit – Schematic created using CircuitLab

  • The circuit does not agree with your description. Are you really using 100kΩ resistors? – Milliways May 30 '16 at 6:56
  • Your code does not even compile. – Milliways May 30 '16 at 7:20
  • As @Milliways suggests it is best to show us the code you are using unless it is very long. Snippets can be confusing, – joan May 30 '16 at 8:02
  • Humble apologies; I had the callback name wrong and I am using 10k resistors. I think it's OK now. – fileinster May 30 '16 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.