Go Down

Topic: Documentation and example code on using firmata client libraries in Java (Read 86 times) previous topic - next topic

I am trying for some time to get documentation on using Java and a firmata client library for the communication between a PC and an arduino. Please note I want to use Java only, i.e., not processing.

Up to no I used the excellent haskell library [hArduino for firmata communication with arduino boards.

Now I am teaching a java course at the university as a Phd student. Therefore I need to use java. However, compared to haskell there is no centralized libraries, pacakges, documentation as with haskell.

So I used google to find more information on using firmata client libraries for java. Unfortunately, the search results are polluted with irrelevant results about processing and javascript. Threfore I ask here.

According to the firmata client library page, there are two java client libraries. However, only 4ntoine seems to be up to date, while the Javarduino
 project seems abandoned.

So I guess the standard way is to use the 4ntoine java client library. Or are there other options?

(I am not interested in Processing or Javascript, i.e., what most google results revile.)

In short, where do I find up to date documentation and example code on using firmata client libraries for Java?

This question is soved.

The mentioned libraries are somewhat outdated, but might be still good as they less rely on native libs and are more pure java implementations.

However, firmata4j (on github) is the new way to do things

Example Code:
package app;

import java.io.IOException;

import org.firmata4j.IODevice;
import org.firmata4j.Pin.Mode;
import org.firmata4j.firmata.FirmataDevice;

public class Application {

   public static void main(String[] args) {
      IODevice device = new FirmataDevice("/dev/ttyUSB0");
      try {
      } catch (IOException e) {
         System.out.println("!! ERROR: device start failed.");
      while ( !device.isReady() ) {
      System.out.println("device is now ready!");
      try {
      } catch (IllegalArgumentException | IOException e) {
         // TODO Auto-generated catch block
      System.out.println("Pin 4 set to OUTPUT mode.");
      try {
         for(int i = 0; i < 1000; i++) {
      } catch (IllegalStateException | IOException | InterruptedException e) {
         // TODO Auto-generated catch block
      System.out.println("Pin 4 set to logic HIGH.");


Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131