Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

Version 1 Next »

To control on the GPIO pins:

  • The external GPIOs are available under the /sys/class/gpio folder in Linux.

  • To control on the GPIO pins you need to calculate the GPIO number XX (*) and run the commands below:

# Export GPIO XX
echo XX > /sys/class/gpio/export

# Set GPIO pin Direction
echo "out" > /sys/class/gpio/gpioXX/direction
or
echo "in" > /sys/class/gpio/gpioXX/direction

# Set the value of an output pin
echo 1 > /sys/class/gpio/gpioXX/value
or
echo 0 > /sys/class/gpio/gpioXX/value

# Get the value of an input pin
cat > /sys/class/gpio/gpioXX/value

# Unexport GPIO XX
echo XX > /sys/class/gpio/unexport


You can calculate the GPIO number XX:
XX = linux gpio number = (gpio_bank - 1) * 32 + gpio_bit

  • No labels