picandies
Posts: 186
Joined: Wed Nov 26, 2014 5:13 pm

need to respond to output pin

Sat Nov 17, 2018 9:17 pm

How can a program react quickly (milliseconds) to an output pin going high? The pin is being set high by another process.
I tried setting up a callback to detect the change, but I get an error that I need to make my output an input!

Code: Select all

GPIO.add_event_detect(14,GPIO.RISING, callback=my_pin_shadower)


User avatar
joan
Posts: 14097
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: need to respond to output pin

Sat Nov 17, 2018 9:30 pm

You could use pigpio which doesn't care if the callback is on an input or an output.

Alternatively you could connect the output pin to a spare pin set as an input and monitor the input pin.

AnneRanch
Posts: 91
Joined: Fri Oct 19, 2018 1:48 pm

Re: need to respond to output pin

Sun Nov 18, 2018 2:27 am

I am not 100% sure how you code "reads" GPIO.
If you go to the BCM register level, you can monitor the pin level independently from pin function - input /output.
Since you use "callback" you could probably use BCM interrupt too.

picandies
Posts: 186
Joined: Wed Nov 26, 2014 5:13 pm

Re: need to respond to output pin

Sun Nov 18, 2018 2:48 am

I'm looking into the pigpio library, but am wondering where a solid tutorial (article, or step-by-step format) is located, for getting things generally set up & working.

I opened some of the code examples, but that's not really an explanation & very few comments are within. The pigrpio site itself seems to have a vast array of commands & their descriptions (a bit overwhelming)--which is good once, you have your feet on the ground & know what's going on. Looking for "pigpio tutorial101"

Return to “General discussion”