[Howto] use GPIO from Raspberry Pi

posted in: computer | 0

the Linux-Kernel manages the GPIO-system under the path /sys/class/gpio. Use the following commands to manage the pins (e.g. GPIO 17):

 

activate GPIO 17:
echo 17 > /sys/class/gpio/export

deactivate GPIO 17:
echo 17 > /sys/class/gpio/unexport

 

configure GPIO 17 as input:
echo in > /sys/class/gpio/gpio17/direction

read the state from GPIO 17:
cat /sys/class/gpio/gpio17/value

 

configure GPIO 17 as ouput:
echo out > /sys/class/gpio/gpio17/direction

set GPIO 17 to low state:
echo 0 > /sys/class/gpio/gpio17/value

set GPIO 17 to high state:
echo 1 > /sys/class/gpio/gpio17/value