Home > JAVA, Orange Pi > Orange Pi Zero GPIO Programming using JAVA

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.

Links :
Install LUBUNTU on Orange Pi Zero
JAVA Applications on Orange Pi Zero

Github Repository: bit.ly/2oEkHDA

Connection Schematic: bit.ly/2oEBgzm
Website (Orange Pi Zero): bit.ly/2i4g9S0

Buy Orange Pi Zero: bit.ly/2ptMSoN

 

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();
    }
}

Schematic:
Subscribe YouTube: goo.gl/FhfdL7

Guys Subscribe to my channel for latest contents into your inbox.
Support me to keep going.

Support me on Patreon : bit.ly/2jcjTSo
___________________________________________

Website : www.weargenius.in
Twitter : twitter.com/geekybikash
YouTube : www.youtube.com/weargenius
Instagram : www.instagram.com/weargenius/
GIT : github.com/oksbwn
Facebook: www.facebook.com/geekybikash

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
  1. No comments yet.
  1. No trackbacks yet.