Go Down

Topic: Trying to read serial data being printed by an Arduino using Processing (Read 2 times) previous topic - next topic

PaulS

Do you KNOW that your Arduino is connected to the 2nd item in the list of serial ports?

You can add print() and println() statements to the Processing sketch, to see whether serialEvent is ever called.

Onceler

In the Arduino IDE, under Tools > Serial Port, "COM3" is selected.  In Processing, when I run my code, the following is produced in the output window at the bottom of the Processing IDE:

Code: [Select]
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version   = RXTX-2.1-7
[0] "COM1"
[1] "COM3"





I think I have the right port entry, but feel free to correct me if I'm wrong. 


If I add

Code: [Select]
println(9999);
inside the "void serialEvent(Serial port)" section, I DO get a bunch of "9999"s printed, at about the same rate as the serial monitor is producing my "BPM" integers. 

PaulS

Quote
inside the "void serialEvent(Serial port)" section, I DO get a bunch of "9999"s printed, at about the same rate as the serial monitor is producing my "BPM" integers.

Why aren't you printing something useful, like inData?

Onceler

Ok, with this:

Code: [Select]
println(inData);

I get the same output as I would normally get in the Arduino's serial monitor. 

PaulS

Quote
I get the same output as I would normally get in the Arduino's serial monitor.

Excellent. So, where did you put that print() statement? Before of after the call to trim()?

What do you get when you print BPM?

Go Up