RPi-Distro / raspi-gpio

Dump the state of the BCM270x GPIOs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to get pin level?

bfallc opened this issue · comments

hi,

In terminal:
raspi-gpio get 4

returns:
GPIO 4: level=0 fsel=0 func=INPUT pull=UP

How can I just get the level, the state of the pin, the "0" or "1" out of this? For example, how can I use this in an if statement to determine pin state?

I'm in bash but any examples of using raspi-gpio in logic would be really awesome, I'm struggling.

Thanks.

Do a string match for level=1 (or level=0).