Using GPIO Pins via sysfs
The GPIO pins available on the 40-pin header can be easily controlled manually via
Please note however, that the
sysfs GPIO interface is deprecated and there may be more suitable alternatives for your application (like a real kernel driver).
First, identify which pins you would like to manipulate by reviewing the 40 Pin 4Kopen Connector page, and take a note of the number in the "sysfs gpio #" column.
Then, using a terminal, try the following:
Writing the number into the export file (e.g: with
echo) will request that the kernel makes this pin available to you, in GPIO mode - it might fail if the pin is already in use by a driver, in which case you may need to investigate your device tree, or use a different pin.
A few important files are made available via the
sysfs GPIO interface;
active_low- whether the signal is inverted
direction- to configure the pin as input or output
value- the pin's current input or output value
More information about this interface can be found in the kernel documentation: https://www.kernel.org/doc/Documentation/gpio/sysfs.txt
Once you have exported your pin, you can manipulate it as follows:
After you have made use of the pin, you may want to return it to the kernel. To do so, simply write the pin's number into the unexport file: