JSSC read sensor value

Hi guys,

I figured out how to use JSSC when i need to write bytes. But i haven't figured out. How i can get value to Java by reading value from arduino analog in.

My code on arduino:

int analogPin = 3;     // potentiometer wiper (middle terminal) connected to analog pin 3

                       // outside leads to ground and +5V

int val = 0;           // variable to store the value read



void setup()

{

  Serial.begin(9600);          //  setup serial

}



void loop()

{

  val = analogRead(analogPin);    // read the input pin

  Serial.println(val);             // debug value

}

But i need to get value in java.

Look up reading from a serial port in Java.

The documentation (Javadocs) for JSSC are included in the download.

If you have studied the JRuby example that I referred you to in another Thread you will see that I used the readBytes() method within JSSC.

It seems to me it would be much more useful for you if you asked all these questions in the same Thread so that people here could see all the background.

...R

Yeah i know i looked JSSC examples, but there aren't Arduino code examples...

I assumed the Arduino code you posted earlier works - I don't see anything wrong with it.

...R

OKey thank you man, i will try it tomorrow :wink:

It doesn't seem to be a good use of your time or mine to post a question here BEFORE you have tested your code.

...R