I've been trying to figure out why the GPIO value will not change. I double check, triple check my connections.
I used GPIO.wait_for_edge(pin, GPIO.RISING) and it executed and when I ran print(GPIO.input(pin)) it prints a 0.

Did I mess up my code an where or what can I do to make it work

Here is an example

import RPi.GPIO as GPIO

# Set the GPIO pin to use
pin = 23

# Set up the GPIO pin as an input
GPIO.setup(pin, GPIO.IN)

while True:
    GPIO.wait_for_edge(pin, GPIO.RISING)
    print(GPIO.input(pin)) # 0

It's hooked up to an arduino the is turning the signal high for .5 seconds the low for .5 seconds There is a voltage divider between the arduino and raspberry p to take it from 5v to 3.3v

  • 2
    I think you need to edit your posting and add in a "working" example program that demonstrates what problem you're seeing.
    – Dougie
    Commented Dec 7, 2022 at 21:54
  • @Dougie I added some working code, the print statement prints a 0, thanks for any help Commented Dec 8, 2022 at 1:53
  • The code is meaningless without details of what is connected. You should also post actual output. (This is rather poor code; it is unclear WHY you would do this.)
    – Milliways
    Commented Dec 8, 2022 at 4:13
  • How long does the rising edge last? It may have gone by the time RPi.GPIO reacts to it.
    – Dougie
    Commented Dec 8, 2022 at 15:41

1 Answer 1


Given on the detail provided by the question alone.

In the time between the GPIO going high (rising edge) and the later reading of the GPIO it has gone from high to low.

There can be a substantial number of milliseconds between these two events in your code.

  • I don't this this is the case b/c I have an arduino turning the signal high, or .5 seconds then turning it low, thanks for the help. Commented Dec 8, 2022 at 17:50
  • We can only answer the question as given. If you had supplied that information in the question you would have gotten a different answer.
    – joan
    Commented Dec 8, 2022 at 18:07
  • Alright well thanks for the help. I think it may be something with my setup Commented Dec 10, 2022 at 1:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.