How do I send data from Eclipse(Java) to the Ardui

Hello,

How can I interface Arduino and Java with eclipse? I am completely lost. I want to be able to send data from eclipse to the arduino board. I am using java to program. Please help.

Thank you. :o

What exactly is your problem?

  • Creating an Eclipse-Plugin or
  • Communication between JAVA and Arduino

I never developed an Eclipse-Plugin. Maybe you should go through some tutorials. Have a look here: http://www.eclipse.org/articles/Article-Your%20First%20Plug-in/YourFirstPlugin.html

Communication between JAVA and Arduino is quite easy. Copy all dll file from your arduino folder into your java project folder. You also need the jars: mrj.jar, registry.jar and RXTXcomm.jar in your classpath.

Here an example java code for reading and sending:

        CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(
                "COM5");

        SerialPort port = (SerialPort) portId.open("serial madness", 4000);
        input = port.getInputStream();
        output = port.getOutputStream();
        port.setSerialPortParams(
                9600,
                SerialPort.DATABITS_8,
                SerialPort.STOPBITS_1,
                SerialPort.PARITY_NONE);

            while (true) {
                while (input.available() > 0) {                    
                    byte[] bytes = new byte[1];
                    bytes[0] = (byte) (input.read());
                    String s = new String(bytes, "ASCII");
                    jTextArea1.append(s);
                }                
                 byte[] bytes = "TEST".getBytes("ASCII");
                 output.write(bytes);
                }
            }
            } catch (Exception ex) {
                ex.printStackTrace();                
            }
        }