Page 1 of 1

Question about reading state of GPIO output

Posted: Wed Jan 20, 2021 9:47 am
by jaypdx
I have some GPIOs I'm using as outputs with code like this:

J2[21].function(PINJ2_21_GPIO);
J2[21] = 1;

I'd like to be able to read the state of these pins, but if I do something like i=J2[21] they change to inputs. I'm using shadow registers to get around this, but I'd like to know if there's an easy way to read the current state of a pin set as an output without switching it to an input?

Re: Question about reading state of GPIO output

Posted: Wed Jan 20, 2021 11:41 am
by pbreed
Not really,
You can read the commanded state...
(you did not say what platform and if you running 3.X or 2.X )

J2[21].readBack(); Should give you the current state without changin the drive/direction setting...