I am working with an example sketch called Graph which is in the Learning section of the Arduino Home Site. I get a consistent error "variable or field 'serialEvent' declared void" when I attempt to compile the code. I'm not sure I'm using the code correctly, as it's printed as an adendum to the code which presents the input as a series of decimal values. Can someone offer some suggestions?
Where are you trying to compile and link that? It is a combination of Processing code and Arduino code that you need to split into two files - one to compile and link in the Arduino IDE and upload the the Arduino, and the other to compile, link, and run using Processing.
I have compiled and uploaded the first part of the sketch using Arduino, and it is running. When I enter the processing code (using Processing), I get the error
Error inside Serial.0
and it fails to compile correctly.
If you wanted to have somewhat of a graph on the serial monitor, you might map the analog input to something like 32 points. Make a Serial.print(); loop printing a * for the number from the maping and end with a Serial.println();. Make the main loop loop every second reading the input and then printing the appropriate number of *. This should produce some what a verticle scrolling graph updaing each second.
Next, using Processing, I load and attempt to compile the processing segment. This is where I get the error message.
I don't understand what's going on here.
It looks like the library you are using is not compatable with your version of processing. You can get older versions of processing so try downgrading it.
'this' is part of the Processing language, and that is part of my problem. I'm not sure I'm using this correctly. I have posted this question on the Processing Forum.
jstanton:
'this' is part of the Processing language, and that is part of my problem. I'm not sure I'm using this correctly. I have posted this question on the Processing Forum.
I understand what the 'this' keyword means, but I don't understand what you intend it to mean within the context of the setup() function. 'this' is defined when you call a function of an object; it points to the object. But setup() is not a function of an object, it is a static function. What do you think 'this' means in that context?
The code is proper Processing code. The setup() function is static, true, but there is an object that this refers to that the Serial class needs in order to do its thing.