Getting access to GPIOs

Now let's look at how we can get access to GPIOs using both the command line (using Bash) and then using the C language.

Bash

Now it's time for an example. A very simple usage is the following one, where we use the gpio91 of the Wandboard to turn an LED on and off. The circuitry is reported in the following figure:

Bash

To control the LED, we must set the line as the output, so we should write out in the /sys/class/gpio/gpio91/direction file, but if we wish to set the LED to a precise state by default, it is better to write low, as show here:

root@wb:~# echo low > /sys/class/gpio/gpio91/direction                          

Note

You can now observe that the ...

Get GNU/Linux Rapid Embedded Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.