I have a device which is based on Raspberry pi. It is known as ionoPi which is basically an i/o expansion board for Raspberry pi. I am writing a python script which detect signal change on input 16 and doing it using interrupts. Below is the code:
import RPi.GPIO as GPIO def di1(pin): di1_status = (GPIO.input(pin)) print("Status of {} is {}".format(pin ,di1_status)) def main(): GPIO.setmode(GPIO.BCM) GPIO.setup(16, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) GPIO.add_event_detect(16, GPIO.BOTH, callback=di1, bouncetime=500) while True: time.sleep(0.5) main() ionoPi board has been powered by 24v power supply. I have a wire which I use to toggle state of di1 which is input 16. To test it continuously, I have attached a button between di1(ipnut 16) and 24v. I have tested the button which works fine. But the code seems to be showing wrong values for the input, refer below image:
so it shows 1,0,1,0,1,0... which is fine and then suddenly it starts showing 0,0,0,0,0,.... I also have attached multimeter which shows that state is changing perfectly fine but somehow this code is showing wrong values. Can anyone please suggest what I am doing wrong here. Thanks.
