I am comfortable writing arduino code and now need to move into processing.
I have a really fundamental question:
In arduino you have functions you can create as well as the standard setup() and loop() functions.
it goes from setup to loop and stays in loop. Any functions I make are not accessible unless called.
I am writing code in processing by modifying some sample programs and noticed that it jumps from Setup but all of the other functions are being run even though they are not called... I thought I needed to call them from within the draw() function but I was wrong.
So how does it work??? are they running simultaneously or are they running from top to bottom on my sketch???
The reason I ask is because I have a function that reads serial inputs called void serialEvent(Serial p) (taken from a razor IMU sample sketch)
it reads data from the serial port, parses it and assigns it to variables.
The function is not called anywhere in the sketch but it is being used either way.
I need to modify the code to read that function x number of times so that the data can be averaged for the sake of smoothing the data.
I tried a for loop around the function but it does not work since the for loop is not within another function.
I creating a loop inside draw() and calling the function from within the loop but that did not work either... I gues I am just not understanding the basic concept of programming in processing.
can someone please help.... I am 90% done with the code as it runs very linear but this problem if "forcing" me to understand what Im doing in order to finish... Who would have thought that you actually need to understand processing in order to program in it ;) sounds silly but with arduino that's pretty much how I learned... the understanding manytimes came after finishing a working sketch...
1