O'Reilly logo

GNU/Linux Rapid Embedded Programming by Rodolfo Giometti

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required