0% found this document useful (0 votes)
137 views

Android App GPIO LED Control Demo

This document provides an example of using Android applications to control GPIO pins on a device to blink an LED light. It explains how to initialize GPIO pins in the sys_config.fex file, import the necessary jar file into an Eclipse project, and write Java source code to set the state of a GPIO pin high or low to turn the LED on and off. The example is intended to demonstrate basic GPIO control that could be expanded into more complex applications.

Uploaded by

Grigoras Cosmin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
137 views

Android App GPIO LED Control Demo

This document provides an example of using Android applications to control GPIO pins on a device to blink an LED light. It explains how to initialize GPIO pins in the sys_config.fex file, import the necessary jar file into an Eclipse project, and write Java source code to set the state of a GPIO pin high or low to turn the LED on and off. The example is intended to demonstrate basic GPIO control that could be expanded into more complex applications.

Uploaded by

Grigoras Cosmin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

http://www.azdisplays.

com

Android Application Dev Example


GPIO control LED light
http://www.azdisplays.com

We can see there are 8 GPIO pins been initialized.

Let me give an example here with the first initialized pin (gpio_pin_1(PH20)), making it as LED
blinking light.

Note: For the definition of GPIO configuration, please view the page http://linux-sunxi.org/GPIO

Alright, based on the configuration of GPIO initialization, next we open the Eclipse develop
program, then import javalib.jar file according to your platform.

1. The location of javalib.jar:

Android4.2/out/host/common/obj/JAVA_LIBRARIES/layoutlib_intermediates/javalib.jar

2. Import

For example, your project name is hello, then go to hello - > Build Path -> Configure Build
Path -> Libraries -> Add External JARs, then choose javalib.jar -> OK

3. Add source code into your APK, please refer to the following example.

JAVA source code:


http://www.azdisplays.com
http://www.azdisplays.com
http://www.azdisplays.com

Note:
a. import android.os.Gpio; is for import the supported controller GPIO pins.
b. Gpio.writeGpio(h, 20, 1);
There are three parameters been set,
1. h means the GPIO pins group.
http://www.azdisplays.com

2. 20 means the exact IO which the first parameter point to.


3. 1 means this PIN is set to HIGH. If 0, it means PIN is set to LOW.

4. The GPIO pin that Application is trying to control, must be initialized by sys_config.fex,

so that this pin is able to be used.

Application UI

5. Conclusion

This is just a simple demo of how to control GPIO pin, you can make more functions based on
the example above.

You might also like