|
Edited by cadinodod at 2021-6-17 03:56
Tutorial How control GPIO whith Android Studio App on Orange Pi 3g and 4g Iot
In this tutorial I will show how control GPIO on Orange Pi 3g Iot and Orange pi 4g Iot using Android Studio app .
First you must have full root access, check this post: Full root access on Orange Pi 3g Iot and Orange Pi 4g Iot
Prerequisites:
1. Android Studio already installed
2. An Orange Pi 3g Iot or Orange pi 4g
3. Jummpers, resistor and Led
Step 1:
1. Creat a Android Studio new project
Step 2:
1. Download the library OrangePi3g4gIot Android
Step 3:
1. Import OrangePi3g4gIotGPIO. Check this post
How use:
- /*To toogle a output gpio*/
- final DigitalWrite digitalWrite = new DigitalWrite(); //create a gpio output object
- digitalWrite.Set(GPIO.GPIO_141_HIGH); // set the state of GPIO141 to HIGH
- digitalWrite.Set(GPIO.GPIO_141_LOW); // set the state of GPIO141 to LOW
- /* for read gpio*/
- final DigitalRead digitalRead = new DigitalRead(GPIO.GPIO_144, GPIO.EN, GPIO.PULLDOWN); //create a gpio input; object the must be have the gpio number, the pull enable (GPIO.EN) and the pull (GPIO.PULLDOWN or GPIO.PULLUP)
- digitalRead.getValue() //read the value of GPIO object created ealiry. It is a integer and can be 0 ou 1
Copy code
Code:
Download code
Demo:
Demo Video
Demo Video 2
Demo video 3 |
|