Hey I am having trouble with creating an array of serial values and using the values. I can get the serial values in, change it to a float and print out the value but I can't seem to find a way to use the values in the circle function. The serial information is coming from a ping sensor through arduino. What I am trying to achieve is
1.put the serial values into a array,
2.get an average value of the serial data from the array
3. pass the average value onto another function - circle()
4. use average value to do stuff
I have added a portion of the code.
import processing.serial.*; Serial myPort; // float [] maxValues; float average, sum; float pulse; float maxValues[] = new float[10];
average = 0; sum = 0;
void serialEvent (Serial myPort) { String bufferString = myPort.readStringUntil('\n'); // get the string from the serial buffer if (bufferString != null) { bufferString = trim(bufferString); // get rid of any whitespace float maxValues = float(bufferString); // declare a variable to hold our value. maxValues = map(maxValues,0,350,0,1); } //in the loop assign a value to each index in the "maxValues" array for(int i = 0; i <= maxValues.length; i++) { maxValues[i] = maxValues[i]; } //to calculate the average sum all the values inside the maxValues array for(int i = 0; i < maxValues.length;) { sum += maxValues[i]; } average = sum/maxValues.length; println(average); }
I've been using processing for a few years now and for the most part its been great to work with but I have one never ending problem - libraries.
For some reason every time i try to install a library it ends up a 3 hour circle of doom installing -restarting -uninstalling!! Over the past week I have installed processing 1.2.1 and tried with little success to install JMyron, JMC and OpenCV each with their various problems and although the forums are good nobody seems to have definite answer . I have managed to install Toxilibs and Moving Letters so it seems to be particularly the video libraries.
I am running win 7 x64, javafx-sdk1.3, Production Suite, jdk1.6.0_20, jre6,k-lite,opencv 1.0(tried 2.2 but won't work at all), directshow , netbeans , jdk1.6.0_23.
Hey, I'm having trouble getting any of the examples to work, I have installed the library in the processing root folder processing1.2.1/libraries/jmyron/library and mydocuments/processing/libraries/jmyron/library folder. I have moved the two .dll files - DSVL.dll and myron_ezcam.dll to both the system32 and processing root folder as well as two additional .dll files that according to an old forum post need to be in the system 32 folder. I have also installed winVDig as well as a number of other codec packs. I'm running windows 7 ultimate x64.
hey i've been trying for 2 days now to install the jmc video library and it still will not work. I had the old library installed with no problems but for some reason i keep getting the same - jmc video library does not exist, you must be missing a library--
At this stage i am so fed up i am about to give up on it completely!! The instructions for installation are utterly crap and I'm sorry to say it but that's the only way to describe it.
I have installed Java, JavaFX 1.3, Netbeans, and production suite. I have copied the relevant files that I could find in the correct folder --- mydocuments/processing/libraries/jmcvideo/library.-------
The files that i could find were from the jmc rar download and I copied the others from the javafx folder. (By the way the path from the instructions is wrong)
The files in the library are
JMC.class,jmc.dll, jmc.jar, jmcMovie.class, jmcmovieGL.class and videoUtils.class.
I have searched for the other files libCoreVideoSupport.jnilib, and jmcServerDaemon everywhere and i can't find them??? I am running windows 7 x64.
Any help would be much appreciated or if anyone knows of a better/easier video library please let me know.