Good afternoon,
Recently purchased an Arduino Leonardo, I am a software developer but is very motivating to make software that communicates with the physical world.
The question is:
I'm working on a project to read data from a temperature sensor and store them in a database.
The reading part of the sensor from Arduino is very simple, I'm going to communicate with Java I searched and there is much info.
I followed this tutorial as it
http://silveiraneto.net/2009/03/01/arduino-and-java/import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
import java.io.InputStream;
import java.io.OutputStream;
import processing.app.Preferences;
public class Main {
static InputStream input;
static OutputStream output;
public static void main(String[] args) throws Exception{
Preferences.init();
System.out.println("Using port: " + Preferences.get("serial.port"));
CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(
Preferences.get("serial.port"));
SerialPort port = (SerialPort)portId.open("serial talk", 4000);
input = port.getInputStream();
output = port.getOutputStream();
port.setSerialPortParams(Preferences.getInteger("serial.debug_rate"),
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
while(true){
while(input.available()>0) {
System.out.print((char)(input.read()));
}
}
}
}
My program does not come to this part:
hile(input.available()>0) {
System.out.print((char)(input.read()));
Any suggestions, the immensely appreciate.