Serial Communication Between an Arduino and a PC with Java

Java

Video is ready, Click Here to View ×


A easy way to communicate between your Arduino and PC. Use the built-in serial port of an Arduino to communicate with a Java program. In this demo, a simple graphical user interface is made with a slider to show the position of a potentiometer. The program could be easily extended to send data from an Arduino to a web site. Check back for more videos on this topic.

This project’s source code:
http://www.farrellf.com/arduino/Main.java

Serial-Comm…

30 thoughts on “Serial Communication Between an Arduino and a PC with Java

  1. Very nice tutorial. As suggested by some folks in th ecomments, changing the "TIMEOUT_READ_SEMI_BLOCKING" to "TIMEOUT_SCANNER" made the code run smoothly. Without this change, the code would stop reading from Serial Port after a few lines of reading. Once I made the change to TIMEOUT_SCANNER, then the code was able to read Arduino continuously. Thank you for creating this awesome tutorial. Very easy to understand and follow.

  2. Hi upgrdman, thanks for those great videos.Could you make another video who combine the read and write from java to the arduino and the opposit way. For example Read 2 sensors from the arduino and show it in java and also to switch 2 outputs of the arduino from java. thanks

  3. Exception in thread "main" java.util.NoSuchElementException
    at java.util.Scanner.throwFor(Scanner.java:862)
    at java.util.Scanner.next(Scanner.java:1485)
    at java.util.Scanner.nextInt(Scanner.java:2117)
    at java.util.Scanner.nextInt(Scanner.java:2076)
    at Test1.main(Test1.java:40)

    i get the output but only limited values are displayed and then i get these exceptions!…and BTW i just executed the arduino program without a potentiometer!

  4. This is really good stuff,i'm a beginner in Java, and i'm very interested in this type of programming,could you make some video about Serial Communication between some other controllers and Java,some PLC controller maybe,like Simens or Schneider .I would appreciate it very much,if not maybe you could give some recommendation to some website or other video where i can learn things like that.

  5. hello , i tried to do the same codes as this one , i am using a 'XY JOYSTİCK'' but im not getting the values although netbeans says we are succesfully connected , what could be the reason??? . after the program sayes we are connected the program tells us succesfully builded and the program stops . i need ur help please.

Leave a Reply

Your email address will not be published. Required fields are marked *