Programming vs. interfacing

Hi everyone,

I’ve been playing around with my Arduino UNO for a while now, and have also been looking for a way to program it in Java (since I’m a Java programmer trying to get into electronics and robotics). I found out about the rxtx library, so that question is pretty much solved for me. However, it felt like using rxtx is a rather “improvised” way to control an Arduino, as the most recent x64 dll-files date back to 2008, leading to mismatches with the current rxtx library etc. Overall, it just didn’t look like the way the Arduino is really meant to be used. So I’ve done some further research and here’s my conclusion so far:

The Arduino is programmed in Arduino language, which is based on C/C++. So, you don’t program an Arduino in Java. You program it by writing that so called “sketch”, a code that’s basically C/C++, in the IDE on your PC, then upload it to your board, where it will run. Everything you do with Java is just interfacing between the Arduino and your PC.

So, my assumption is that in real-life robotics, you program your Arduino (if you choose this as your microprocessor) with an Arduino sketch. Inputs are taken through the reading pins or by somehow hooking it up to an R/C (right…?). If you still need to connect it to your PC (for example because the main part of your system is the software, rather than the robot) you have to find a way to let your board and PC interface. For Java, rxtx is that interface, but they also exist for many other languages and software.

Now, my question is actually twofold: first of all, what do you think about my conclusion? Is it more or less accurate or did I understand this all wrong?

Secondly, just out of curiosity: how do developers go about creating such an interface? You have an Arduino, a USB cable, and a PC, now what do you do? What type of code do you need to write (C, Assembly, …), what files do you have to build (dll, …), …? I assume you have to get a lot of specifications from the manufacturer as well, about how signals are being read, interpreted, sent, etc., right? Not that I have any intention of building such an interface on my own, it just annoys me when I use something and have no idea how and why it works :stuck_out_tongue_winking_eye:

Best,
Silas

The JSSC library seems to have replaced RXTX and I think it is easier to use.

C/C++ is the only language for programming an Arduino. The Arduino IDE makes that relatively painless.

Look at the examples in Serial Input Basics for simple reliable code to receive data. The system in the 3rd example will be most reliable.

It should be straightforward to get a Java program to send data in that format.

As far as communicating between a PC and an Arduino is concerned sending Serial messages over the standard USB cable is the obvious option. You can also send Serial messages by Bluetooth as easily if you have a bluetooth module for the Arduino.

After that things get a bit more complex. You could use an ESP8266 module with an Arduino to connect via WiFi. Or you could use two Arduinos (my preferred option) with one connnected to the PC by USB cable and communicating with the other Arduino using nRF24L01+ 2.4GHz transceivers (which are very cheap).

...R

Robin2:
The JSSC library seems to have replaced RXTX and I think it is easier to use.

C/C++ is the only language for programming an Arduino. The Arduino IDE makes that relatively painless.

Look at the examples in Serial Input Basics for simple reliable code to receive data. The system in the 3rd example will be most reliable.

It should be straightforward to get a Java program to send data in that format.

As far as communicating between a PC and an Arduino is concerned sending Serial messages over the standard USB cable is the obvious option. You can also send Serial messages by Bluetooth as easily if you have a bluetooth module for the Arduino.

After that things get a bit more complex. You could use an ESP8266 module with an Arduino to connect via WiFi. Or you could use two Arduinos (my preferred option) with one connnected to the PC by USB cable and communicating with the other Arduino using nRF24L01+ 2.4GHz transceivers (which are very cheap).

...R

Hi R

Thank you very much for this great reply! I'll definitely try the JSSC and check out the examples, thanks.

Best,
Silas

I should have said that my experience with the JSSC library (and, prior to that RxTx) is from using it with JRuby (which runs on the JVM) so it is certainly possible to communicate with an Arduino using Java.

...R