Tag Archives: Raspberry Pi

More Raspberry Pi Awesomeness: GPIO & Java

I’ve been playing with the GPIO capabilities of the Raspberry Pi before using Python, which comes with easy GPIO access for the Raspberry Pi.

Java 8 for ARM

As I’m yet not very familiar with Python I got excited when Oracle accounced Java 8 for the ARM platform, so I downloaded the JDK 8 (with JavaFX) for ARM Early Access from the Oracle website, copied it to the RPi, compiled an example app on my PC and copied the JAR to the RPi – and it runs!

Obviously it takes some time to start the application but it works as excepted; of course it was a very simple example and there are some limitations, especially when it comes to graphics output, but it’s a good start.

There is even JavaFX support in the JDK 8 which will output to RPi’s HDMI/Video output, but that’s a topic for another posting ;)

Java & GPIO

There is no native support for the RPi’s GPIO pins in Java, but there are two Open Source projects to get it running anyway:

  • WiringPi – an easy-to-use C library to control the GPIO pins
  • Pi4j – a Java class library providing a bridge between native code and Java to access the GPIO pins

As described on the WiringPi website you can get WiringPi via git, and then build it directly on the RPi.

The Pi4j website has lots of examples on how to work with the code, and from a Java developer’s perspective it is pretty straight forward to use Pi4j.

I’ve used some code directly from the Pi4j’s example pages, put an LED on a breadboard, connected two pins and when running the program the LED blinks! Great!

So, if you are planing to access GPIO via Java you should definitely take a look at WiringPi and Pi4j.

Raspberry Pi & GPIO & LCD = awesome

Do you remember the LCD display? I’ve connected it successfully to an Arduino lately, so when I got my Raspberry Pi some days ago it was just a matter of time to try connecting the two:

Raspberry Pi with LCD

I followed the nice instructions by Adafruit, connected all the wires, ran the code, and everything worked great.

The code is written in Python, so that’s maybe the next language to learn for me ;)

The GPIO capabilities of the Raspberry Pi look very promising, so I might use them regularly in future projects, especially when a decent amount of storage or a network connection is required (both provided by the Raspberry Pi in a very convenient way).