I want to know the basics of arduinoArduino serial comunicationscommunications and connection with a javaJava application in windowsWindows.
Can anybody provide me with a sample javaJava program that on runupon running just makes an arduinoArduino pin high as well as the according arduinocorresponding Arduino sketch
, and some explenationexplanation on how the arduino comunicatesArduino communicates with the javaJava app?
I am now starting with arduinoArduino,
and I have some experience with javaJava
I found this code on the net - will this work?
JAVA CODEJava code
package arduino;
import jssc.SerialPort;
import jssc.SerialPortException;
public class Arduino {
public static void main(String[] args) throws InterruptedException {
SerialPort serialPort = new SerialPort("COM3");
try {
System.out.println("Port opened: " + serialPort.openPort());
System.out.println("Params setted: " + serialPort.setParams(9600, 8, 1, 0));
System.out.println("\"Hello World!!!\" successfully writen to port: " + serialPort.writeBytes("o".getBytes()));
Thread.sleep(1000);
System.out.println("\"Hello World!!!\" successfully writen to port: " + serialPort.writeBytes("f".getBytes()));
System.out.println("Port closed: " + serialPort.closePort());
} catch (SerialPortException ex) {
System.out.println(ex);
}
}
}
ARDUINOArduino