How can I control GPIO's in Linux user-space?

To see the current status of GPIO's in Linux user-space:

cat /sys/kernel/debug/gpio

Choose the GPIO you would like to control, export it to become a sysfs node, in this example GPIO 23

echo 23 > /sys/class/gpio/export

Set it as "i an input or output by echoing "in" or "out":

echo out > /sys/class/gpio/gpio23/direction

Now set it high "1", or low "0":

echo 1 > /sys/class/gpio/gpio23/value

You can check your work by performing the cat command again.

Categories