We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi Everyone! I'm a bit new to Processing and Arduino, so I apologize if this is basic task whose answer I may have missed.
What I'm trying to do is read in a continuous stream of data from a tachometer circuit I made with Arudino, and then feed it into Processing; which I've successfully done using the code below:
if (0 < port.available()) { val = port.read(); println(val); }
What I'm not sure how to do is process the data so that whenever a certain value is detected, an event will occur in Processing.
Thank you! Nick
Answers
Dunno! Perhaps something like this 1? :-/
Hey there! Thanks for your answer. That's sort of what I ended up trying. I put my code below...perhaps that will help explain what I am trying to do (I should have done that much sooner!)
Basically, I'm using an Arduino Uno to calculate the speed of a computer fan. If the fan stays at 3600 rpm, then I want a movie to play. If it drops below that, I want the movie to stop playing. My Arduino sketch is working (I'm able to read in the data fine on the serial port), but for some reason I can't do that with Processing; no data appears to be coming in. I based this off of other serial read examples I found, but nothing seems to work yet.
It's difficult to debug without seeing the Arduino side of the code as well.
Two things to check: 1. All other serial monitors and applications reading in from that port are closed (only one application can read from a serial port at a time). 2. Your data from the Arduino actually terminates with a \n, so it should be using Serial.println not Serial.print.
Additionally, have you gotten the other serial examples that you've found working?
Right, how silly....here's the Arduino code I'm using:
In regards to your suggestions: 1. Yes, I don't have any other serial applications open. 2. I did try changing my Arduino code from 'Serial.print' to 'Serial.println', but it didn't seem to have any effect.
And yes, I did get the following example to work fine; it reads in data from a potentiometer on pin 0.
edit: @theleadingzero, The other serial example that I got to work was the 'SerialEvent' sketch included under File/Examples/Communication.