Android App GPIO LED Control Demo
Android App GPIO LED Control Demo
com
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.
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.
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
4. The GPIO pin that Application is trying to control, must be initialized by sys_config.fex,
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.