Orange Pi Zero GPIO Programming using JAVA

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:

oksbwn/OrangePi_Zero_GPIO_Demo

A simple java application to access GPIO of Orange Pi Zero using Pi4J and JAVA.

0 forks. 0 stars. 0 open issues.

Last commit by

Connection Diagram:
Orange Pi Schematic
Orange Pi Schematic
Buy Orange Pi Zero:
Links:
Bikash Panda
Catch Me On

Bikash Panda

Blogger / Embedded System Developer at WeArGenius
A techie, tinkerer and tech lover, who loves to blog and feels everyone can learn tech provided they have the right attitude towards learning and passion. By profession, I am an IOT developer working in Smart Home/ Smart Grid domain.
Bikash Panda
Catch Me On

Bikash Panda

A techie, tinkerer and tech lover, who loves to blog and feels everyone can learn tech provided they have the right attitude towards learning and passion. By profession, I am an IOT developer working in Smart Home/ Smart Grid domain.