Orange Pi Zero GPIO Programming using JAVA

Orange Pi Zero GPIO

Orange Pi Zero GPIO ProgrammingThis is a simple tutorial on Orange Pi Zero GPIO Programming using JAVA. For this, I have used Pi4J library which also works with Raspberry Pi. This tutorial might help you to interact with GPIO in your IOT projects. In his tutorial, I have tested the application with LUBUNTU OS on Orange Pi Zero.

 

 

 

 

Video:
Code:
import com.pi4j.io.gpio.*;
import com.pi4j.platform.Platform;
import com.pi4j.platform.PlatformAlreadyAssignedException;
import com.pi4j.platform.PlatformManager;

public class Mainclass {

    public static void main(String[] args) throws InterruptedException, PlatformAlreadyAssignedException {

    	System.out.println("Starting Demo");
        PlatformManager.setPlatform(Platform.ORANGEPI); // Support for Orange Pi

        final GpioController gpio = GpioFactory.getInstance();

        GpioPinDigitalInput inputPin = gpio.provisionDigitalInputPin(OrangePiPin.GPIO_00,PinPullResistance.PULL_UP);// Pulled UP
        GpioPinDigitalOutput outputPin = gpio.provisionDigitalOutputPin(OrangePiPin.GPIO_07);
        while(true){
        if(inputPin.isLow()){// Checks if switch is pressed.

        	System.out.println("Switch is pressed.");
        	outputPin.low();
        }
        else{
        	outputPin.high();
        }
        }
       // gpio.shutdown();
    }
}
Repository:
Connection Diagram:
Orange Pi Schematic
Orange Pi Schematic
Buy Orange Pi Zero:
Links: