Basic Java to Ardunio uno serial communtication

Hey everyone,

I am working on a project that is supposed to read in a barcode from a camera and output the number of the barcode to a screen. So far I have it working solely in Java. However, I need it to communicate with the Arduino uno.

I am very new to Arduino and using micro controllers in general ( I have had a class on them where we made a car but I dont remember much from it). All I need the Arduino to do is output the text to an LCD screen (its already been soldered onto the Arduino) and have it run my Java program every time a button is pressed (also already connected to the board). I know the pin numbers for both the button and the LCD and can confirm that they work. What I dont understand is how to now communicate with the Arduino through Java and vice versa.

Does there need to be C code in the Arduino IDE sketch pad thing or can I do this ONLY through Java? Should the Java code be listening for the button press or should there be C code in the arduino listening for the button that then tells it to run the Java code? How would I even do this through Java?

Im really new to this kind of PC (w/ Java) -> Arduino communication.

Thanks in advance.

Not sure I fully understand your question, anyway I'll try to give you some hints:

  • java doens't work on Arduino. Arduino is programmed in c++.
  • Arduino and a PC usually communicate through the virtual serial port created by the usb connection, so with Java it's with all other programming languages: find out the name of the serial port Arduino is connected to and use whatever method the language provides to send and receive bytes through that (standard-looking) serial port.

My 2 cents.