Introduction: DragonBoard: How to Access GPIOs Using C++

About: Computer Engineering at Inatel

The DragonBoard™ 410c is the first development board based on a Qualcomm® Snapdragon™ 400 series processor. It features advanced processing power, Wi-Fi, Bluetooth connectivity, and GPS, all packed into a board the size of a credit card. Based on the 64-bit capable Snapdragon 410E processor, the DragonBoard 410c is designed to support rapid software development, education and prototyping, and is compliant with the 96Boards Consumer Edition specification. All this makes it ideal for enabling embedded computing and Internet of Things (IoT) products, including the next generation of robotics, cameras, medical devices, vending machines, smart buildings, digital signage, casino gaming consoles, and much more.

In this tutorial you will learn how to access the GPIO of the boards using C++ Language from Linux GPIO.

List of Material:

1 - Dragonboard410c

1 - 96Boards sensors board

1- Grove Button

1 - Grove LED

Step 1: Installing G++ Compiler

First, update the package index.

$ sudo apt-get update

Now, you can install the G++ compiler with the following command:

$ sudo apt-get install build-essential

Step 2: Download Source Code

Download the source code below:

Step 3: Dragonboard GPIO Pin Mappings

This picture shows DragonBoard GPIO pins mappings.

In the source code to access a GPIO pin, call function for a specific GPIO pin.

For example:

* Get pin 23;

* @returns {Gpio}


Gpio* GpioProcessor::getPin23() {

return getPin((char *)"36");


This method will give access to the GPIO pin 23.

Step 4: Set GPIO Direction.

In file Gpio.h has methods to set GPIO direction.

Set GPIO pin as output:

void Gpio::out() {
setDirection((char *)"out");


Set GPIO pin as input:

void Gpio::in() {
setDirection((char *)"in");


For reading GPIO direction, call function "getValue".

Step 5: Read and Write Values on GPIO

In the Gpio.h there are methods to read and write values on GPIO pin.

Set GPIO pin as High level:

void Gpio::high() {
setValue((char *)HIGH);


Set GPIO as Low level:

void Gpio::low() {
setValue((char *)LOW);


Call function "getValue" to read value from GPIO.

Step 6: Release Access to the GPIO Pin

After using GPIO pin, it is necessary release access to the GPIO pin.

Call function "cleanPins()" in GpioProcessor.h to remove access of pin.

void GpioProcessor::cleanPins() {
for (unsigned i = 0; i < pins.size(); i++) {





The "unexportPin" function will disable access to the GPIO and remove the corresponding directory.

Step 7: Blink Led After Pressing Button

The Main.cpp runs an example that blink led after pressing button during 20 seconds.

In this example we are accessing pin 27 for blink led and pin 29 to read button status.

After 20 seconds, both GPIO's are released.

To run the example, it's necessary complile the cpp files.

$ g++ Main.cpp -o main

It is necessary give access to the generate file

$ sudo chomod +x main

Run file $ ./main

Step 8: References