Skip to main content Skip to local navigation

Java and Arduino: Serial Communication

Java and Arduino: Serial Communication

Before we started using Firmata and Firmata4j in the EECS 1021 class, Richard Robinson and I put together lab activities that used the Fazecast jSerialComm library paired with customized Arduino serial code.

The approach is summarized in three videos:

Video 1: The Plan for Sending Data to an Arduino

We need to send information, in this case a countdown sequence, to an Arduino from a Java program on a PC (macOS, Windows, etc.). We're assuming that you've already got a C++ program running on the Arduino (or similar) microcontroller board. Let's plan out an approach to a thread-based Java program that sends a byte of information at a time at regular (1 second) intervals.

Part 1 of sending data to an Arduino from Java using jSerialComm

Video 2: The Implementation for sending data to the Arduino from Java

Here we go through the actual implementation for how we send data from a Java program to an Arduino using the jSerialComm library.

Second part: implementation.

Video 3: Receiving Arduino data in Java

So, you want to send a signal to your Java program from an Arduino. How do you do that? Here we go over a ``simple'' example.

PDF Document: Arduino & Java Lab

Here is the PDF of the Lab document:


a pen

James Andrew Smith is a Professional Engineer and Associate Professor in the Electrical Engineering and Computer Science Department of York University's Lassonde School, with degrees in Electrical and Mechanical Engineering from the University of Alberta and McGill University.  Previously a program director in biomedical engineering, his research background spans robotics, locomotion, human birth and engineering education. While on sabbatical in 2018-19 with his wife and kids he lived in Strasbourg, France and he taught at the INSA Strasbourg and Hochschule Karlsruhe and wrote about his personal and professional perspectives.  James is a proponent of using social media to advocate for justice, equity, diversity and inclusion as well as evidence-based applications of research in the public sphere. You can find him on Twitter. Originally from Québec City, he now lives in Toronto, Canada.